File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JMS queue in Websphere 5.0 - Class Cast Exception!

 
dmf fernando
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are trying to connect to JMS queue in Websphere 5.0 through a java client and having a problem with casting the lookup Queue Connection factory to the relevant object.
1) get Initial Context :
{
Hashtable env = new Hashtable();
env.put(Context.PROVIDER_URL,"iiop://test:2809");
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
initialContext = (Context) new InitialContext(env);
}
2) After having initial context ,we try to lookup the queue connection Factory (Successfully lookup the and got "obj" ,but failed at Casting obj to QueueConnectionFactory):

Code is as follow:
import javax.jms.*;
..
{

Object obj = initialContext.lookup(strConnectionFactory);

QueueConnectionFactory Qcf = (QueueConnectionFactory)obj; ////This gives the exception

// Qcf = (QueueConnectionFactory)initialContext.lookup(strConnectionFactory); //This ALSO gave the exception


//Qcf = (ConnectionFactory) PortableRemoteObject.narrow(obj, javax.jms.QueueConnectionFactory.class);


}

3) This is the error message:
ERROR [2003-01-22 19:55:47,713](MISMessageProducer.java:109) - java.lang.ClassCastException: javax.naming.Reference

Hope someone can help with this.
 
Subhash Namboodiri
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi fernando,
A similar problem is already mentioned in this group few days back may be you want to check it out. Anyway for a quick solution just check if
1. namingClient.jar
2. messagingClient.jar
3. naming.jar
4. ecutils.jar
ARE present in the CLASSPATH. If all are there in the CLASSPATH it should solve your problem
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And I will say what I said last time. DO NOT, I REPEAT DO NOT LAUNCH A JAVA CLIENT FOR WEBSPHERE IN ANY OTHER WAY OTHER THAN USING LAUNCHCLIENT.BAT!!!
USING LAUNCHCLIENT.BAT WILL FIX ALL OF THESE PROBLEMS!! It is the ONLY supported way to run Java clients for WebSphere, the ONLY way! IBM will NOT, I repeat NOT guarantee that it will work any other way! DO NOT GO MESSING WITH YOUR CLASSPATH!!!
Kyle
 
dmf fernando
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the solutions.
We tried with editing the classpaths... and it dind't work.
So we will try the LAUNCHCLIENT.BAT and see.
Thanks again!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic