• Post Reply Bookmark Topic Watch Topic
  • New Topic

JMS Problem

 
Nikhil Dole
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I am getting following exception and the code is also mentioned below i tried to add the following jars in classpath but still it did not work.Please help.
messagingClient.jar,namingClient.jar,naming.jar and euutils.jar.

Exception->
java.lang.ClassCastException: javax.naming.Reference
at com.cardinal.test.ejb3.messaging.service.JMSClient.main(JMSClient.java:49)

Code-> Object obj = jndiContext.lookup("queue/messaging");
System.out.println("queue "+obj);
Queue queue = (Queue)obj;***** classcastexception

Thanks,
Nikhil Dole
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Javaranch.
You are attempting to cast an instance of javax.naming.Reference to the type of Queue. This cannot be done.
Reference is used to decouple resources from the JNDI. You need to obtain a reference to it and use it to discover where your queue instance is.
 
Nikhil Dole
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code was working in some other machine , I believe that this has to do with putting some jars in classpath.If not how should we modify the code to make it work , many people have got the same problem for QueConnectionFactory class and putting some jars in classpath solved their problem.What do i need to do?
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the problem where the classpath I'd expect that you would get a ClassNotFoundException. ClassCastExceptions are caused by attempting to cast an instance of one class to to another unrelated class.
What does the complete stack trace look like?
If you are working on different machines, are you using the same JNDI directory? If you are not, you could be putting different things into the JNDI with the same key.
[ September 12, 2006: Message edited by: Joe Ess ]
 
Nikhil Dole
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Added few jars in the classpath and it worked.
e.g. jbossmq.jar
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!