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.
