JMS Client not Running from the command prompt , but running well from servlet
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sathiya_Narayanan
Posted On:   Monday, September 29, 2003 01:40 PM

Hi I have wrote a JMS Client program (Servlet) which is running just fine.I mean, I am able to put the message in the queue by calling the servlet. I took the same code and wrote a stand alone java application , and when I ran the , it throwing an error like "Classcast exception, naming reference" when it look up the Queue Connection factory..I'm using Websphere 5.0.1 and windows xp. here is code : InitialContext ctx = new InitialContext(); Object cfObject = ctx.lookup("jms/TestQCF"); QueueConnectionFactory qcf = (QueueConnectionFactory) PortableRemoteObject.narrow(cfObject, QueueConnectionFactory.class); // Cre   More>>

Hi


I have wrote a JMS Client program (Servlet) which is
running just fine.I mean, I am able to put the message
in the queue by calling the servlet. I took the
same code and wrote a stand alone java application ,
and when I ran the , it throwing an error
like "Classcast exception, naming reference" when it
look up the Queue Connection factory..I'm using
Websphere 5.0.1 and windows xp. here is code :


InitialContext ctx = new InitialContext();

Object cfObject = ctx.lookup("jms/TestQCF");

QueueConnectionFactory qcf = (QueueConnectionFactory) PortableRemoteObject.narrow(cfObject, QueueConnectionFactory.class);


// Create a QueueConnection

QueueConnection conn = qcf.createQueueConnection();


//Create a QueueSession

QueueSession session = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);


// Look up the Queue in JNDI

Object qObject = ctx.lookup("jms/TestQueue");

Queue q = (Queue) PortableRemoteObject.narrow(qObject, Queue.class);


// Create a QueueSender

QueueSender sender = session.createSender(q);


// Create a message

java.util.Hashtable hasMsg = new Hashtable();

hasMsg.put("one", "Message_ONE");

hasMsg.put("two", "Message_TWO");

hasMsg.put("three", "Message_THREE");


ObjectMessage message = session.createObjectMessage();

message.setObject(hasMsg);


// Send the message

sender.send(message);


This is the client environment :


%MQ_JAVA_INSTALL_PATH%libconnector.jar;

%MQ_JAVA_INSTALL_PATH%libjms.jar;

%MQ_JAVA_INSTALL_PATH%libcom.ibm.mqjms.jar;

%MQ_JAVA_INSTALL_PATH%libcom.ibm.mq.jar;

%WAS_HOME%properties;

%WAS_HOME%lib
s.jar;

%WAS_HOME%lib
aming.jar;

%WAS_HOME%lib
amingclient.jar;

%WAS_HOME%libecutils.jar;


I would appreciate if anyone help why its not running from
the command prompt and working well in servlet.

   <<Less

Re: JMS Client not Running from the command prompt , but running well from servlet

Posted By:   Nicholas_Whitehead  
Posted On:   Tuesday, September 30, 2003 08:41 AM

Sathiya;

Most likely, the JNDI tree does not look the same from a command line client's perspective, as it does from the servlet which is running in the same VM as the servlet.

Get yourself a JNDI browser, (I think MQ supplies one called JMSAdmin) or write the JNDI code to dump the JNDI tree contents, and I think you will be able to determine a different lookup string when you are looking up objects.

//Nicholas

About | Sitemap | Contact