Hi
I am trying to create a stand-alone client to Websphere MQ JMS using
the following simple code:
Hashtable h = new Hashtable();
h.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
//h.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
h.put(Context.PROVIDER_URL,"iiop://localhost:2809");
Context context = new InitialContext(h);
System.out.println("Initial Context obtained");
Object o = context.lookup("jms/qcf");
System.out.println("QueueConnectionFactory obtained as object");
System.out.println(o.getClass().getName());
System.out.println(o.toString());
QueueConnectionFactory qcf =
(QueueConnectionFactory)context.lookup("jms/qcf");
and it fails while casting to QueueConnectionFactory (context is
fine).
java.lang.ClassCastException: javax.naming.Reference
I include all the required JARS from base_v5/lib and
base_v5/mqjms/java/lib and the implFactory.jar from
wstools/eclipse/plugin folder and the java/javac from
base_v5\java\bin.
Any help would be much appreciated.
Sincerely
Rajneesh
-
JMS-JNDI-QConnectionFactory lookup-WSAD 5.1 (4 messages)
- Posted by: rajneesh jindia
- Posted on: September 18 2004 07:30 EDT
Threaded Messages (4)
- JMS-JNDI-QConnectionFactory lookup-WSAD 5.1 by Sr ini on September 20 2004 02:49 EDT
- Check references... by server side on June 24 2005 05:36 EDT
- Check references... by Brian Hardy on August 03 2005 02:10 EDT
- Check references... by server side on June 24 2005 05:36 EDT
- Exception in thread "P=511618:O=0:CT" java.lang.ClassCastExcepti by jackson george on June 28 2006 15:00 EDT
-
JMS-JNDI-QConnectionFactory lookup-WSAD 5.1[ Go to top ]
- Posted by: Sr ini
- Posted on: September 20 2004 02:49 EDT
- in response to rajneesh jindia
Hi Rajineesh,
I used the following code to post a message to Websphere MQ.
Chk whether it's useful.
Rgds
Srini - TCS
public void writeMessageToMQ(Message message)
{
String s1="";
try
{
s1 = ((TextMessage)message).getText();
}
catch (Exception e)
{ System.out.println("Error while converting in to String");
e.printStackTrace();
}
Hashtable properties= new Hashtable();
MQQueueManager qMgr;
System.out.println(" getMQ property file");
ResourceBundle mqResource = ResourceBundle.getBundle("MQResources");
String hostname = mqResource.getString("hostname");
String transportvalue = mqResource.getString("transport");
String portvalue = mqResource.getString("port");
String channelvalue = mqResource.getString("channel");
String qmvalue = mqResource.getString("queuemanager");
String qvalue = mqResource.getString("queue");
properties.put("port", new Integer(Integer.parseInt(portvalue)));
properties.put("hostname", hostname);
properties.put("transport", transportvalue);
if(channelvalue != null)
properties.put("channel", channelvalue);
MQEnvironment.hostname = hostname;
MQEnvironment.channel = channelvalue;
try {
System.out.println("Posting in to MQ");
qMgr = new MQQueueManager(qmvalue,properties);
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT ;
MQQueue queue = qMgr.accessQueue(qvalue,openOptions);
MQMessage inputMessage = new MQMessage();
inputMessage.format=MQC.MQFMT_STRING;
inputMessage.writeString(s1);
MQPutMessageOptions pmo = new MQPutMessageOptions();
queue.put(inputMessage,pmo);
System.out.println("Posted in to MQ Queue");
}
catch(Exception e)
{ e.printStackTrace();
System.out.println("Some problem in posting");
}
} -
Check references...[ Go to top ]
- Posted by: server side
- Posted on: June 24 2005 05:36 EDT
- in response to Sr ini
Hello,
ich you get an class-cast exception, check if
your references can be resolved, the jndi
has the nasty behaviour to return a reference object
itself if it cannot be resolved.
Stefan -
Check references...[ Go to top ]
- Posted by: Brian Hardy
- Posted on: August 03 2005 02:10 EDT
- in response to server side
Hello,ich you get an class-cast exception, check ifyour references can be resolved, the jndihas the nasty behaviour to return a reference objectitself if it cannot be resolved.Stefan
What do you mean exactly by "see if your references can be resolved"? -
Exception in thread "P=511618:O=0:CT" java.lang.ClassCastExcepti[ Go to top ]
- Posted by: jackson george
- Posted on: June 28 2006 15:00 EDT
- in response to rajneesh jindia
You have to add ‘messagingClient.jar’ in your WSAD Run->RUN xxx->ClassPath. This should solve the issue. I got this error and I solved this. --------------------- jgeorge at itprototype dot com www.itprototype.com