classcastexception jndi lookup
Hi,
I am getting a java.lang.ClassCastException when I try to do a JNDI lookup of a JMS QueueConnectionFactory or a Queue (javax.jms.Queue) object. I have created the QueueConnectionFactory and a Queue JMS objects using the admin GUI of Sun App Server ver 8. I am doing the JNDI lookup from inside a message driven bean. I am able to configure the MDB to trigger properly using the same Queue Connection Factory. Please find the code I am using below:
javax.naming.Context ctx = new javax.naming.InitialContext();
System.out.println("About to lookup Queue");
javax.jms.Queue Q=(javax.jms.Queue) ctx.lookup("java:comp/env/jms/MDBOutQ");
System.out.println("About to lookup Conn Fact");
javax.jms.QueueConnectionFactory QCF=(javax.jms.QueueConnectionFactory) ctx.lookup("java:comp/env/jms/MDBTestDestinationFactory");
One workaround I found in this forum is to define the JMS objects as a resource reference in the MDB (ejb-jar.xml) file.
<resource-ref>
<res-ref-name>jms/MDBOutQ</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
I did that and I was able to get one of the lookups (either Queue or QCF) to work. The other lookup is not working since it is not possible to define 2 resource references for the same MDB. So, I need a way to get the lookups to work without using resource references. I know that the JMS objects are being found since if I change the name it gives a different error saying "Object not found".
Please help.
Thanks
Bhaskar

