This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
hi there, I am test MDB using WSAD and so far I have put the QueueFactory and Queue etc in the server, deploy the bean and server runs fine on localhost. Then I put this code as my client, There is one line here test the class type I got back from JNDI lookup and the type is javax.naming.Reference Then, I cut&paste the same logic put in struts.war logonAction.java and deploy war in my test EAR file, deploy on WAS5.0 Test server, now it runs, I see the message published and this time, class type I got back from JNDI lookup is class com.ibm.ejs.jms.JMSQueueConnectionFactoryHandle Well, I spent couple hrs to figure out how to run JMS client as a stand alone application, and finally, still, cannt beat it I attached my test client here, anyone on this board have been able to successfully run a standalone JMS client and using Websphere, please shed some light. Realy appreciate it. Thanks -Ying ------------------------------ code here ---------------------------- import javax.jms.Message; import javax.jms.MapMessage; import javax.jms.Session; import javax.jms.QueueConnectionFactory; import javax.jms.QueueConnection; import javax.jms.QueueSession; import javax.jms.Queue; import javax.jms.QueueSender; import javax.jms.JMSException; import javax.naming.Context; import javax.naming.Reference; import javax.naming.RefAddr; import javax.naming.InitialContext; import java.util.Properties; import java.util.Date; import java.util.*;
public class JmsClient { public static void main(String [] args) throws Exception {
Integer cruiseID = new Integer(111); //new Integer(args[0]); int count = 10; //new Integer(args[1]).intValue(); Context jndiContext = getInitialContext();
for (int i = 0; i < count; i++) { MapMessage message = session.createMapMessage();
//message.setJMSReplyTo(ticketQueue); // Used in ReservationProcessor to send Tickets back out message.setStringProperty("MessageFormat", "Version 3.4"); message.setInt("CruiseID", 111); message.setInt("CustomerID",i%2+1); // either Customer 1 or 2, all we've got in database message.setInt("CabinID",i%10+100); // cabins 100-109 only message.setDouble("Price", (double)1000+i);
// the card expires in about 30 days Date expDate = new Date(System.currentTimeMillis()+43200000);
public static Context getInitialContext() throws javax.naming.NamingException { java.util.Properties properties = new java.util.Properties(); properties.put(javax.naming.Context.PROVIDER_URL, "iiop://localhost/"); properties.put( javax.naming.Context.INITIAL_CONTEXT_FACTORY, //"com.ibm.ejs.ns.jndi.CNInitialContextFactory"); //"com.ibm.ws.naming.util.WsnInitCtxFactory"); "com.ibm.websphere.naming.WsnInitialContextFactory"); InitialContext initialContext = new InitialContext(properties); return initialContext; } }
Kyle Brown
author
Ranch Hand
Joined: Aug 10, 2001
Posts: 3879
posted
0
Place your code in a J2EE application Client JAR file inside your EAR file. Run the client using the launchClient tool. That shoudl solve the problem. Kyle
Howard Kushner<br />IBM Certified Enterprise Developer - WebSphere Studio Application Developer V5.0<br />IBM Certified Advanced System Administrator - WebSphere Application Server V5.0<br />IBM Certified Solution Developer - Web Services with WebSphere Studio V5.1<br /><a href="http://www.amazon.com/exec/obidos/tg/detail/-/1931182108/" target="_blank" rel="nofollow">Developing J2EE Applications with WebSphere Studio</a> my Certification Study Guide for IBM Test 287
siva kumar
Ranch Hand
Joined: Sep 03, 2004
Posts: 86
posted
0
HI Kyle,
I have configured the listener port for my p2p MDB using AdminConsole
while restarting the server i'm getting follwing errors
Unable to lookup JMS resources, JNDI lookup exception: com.ibm.ejs.jms.JMSQueueConnectionFactoryHandle Unable to start MDB Listener Message, JMSDestination QCF : java.lang.ClassCastException: com.ibm.ejs.jms.JMSQueueConnectionFactoryHandle
Failed to start MDB Message against listener port MessageListener
and while running the application I'm getting the following exception
javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for 'localhost:WAS_localhost_server1' at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:556) at com.ibm.mq.jms.MQConnection.createQM(MQConnection.java:1736) at com.ibm.mq.jms.MQConnection.createQMNonXA(MQConnection.java:1129) at com.ibm.mq.jms.MQQueueConnection.<init>(MQQueueConnection.java:170)
I haven't installed MQ series separatly.
I'm running the application from WSAD .
Can you please assit me to solve the problem
Goutam Bhattacharjee
Ranch Hand
Joined: Aug 05, 2003
Posts: 44
posted
0
I had this problem initially when I tried to test an MDB. I am also testing the MDB within WSAD, and have not installed MQ-Series separately. After I got this error, I did some trial & error and it finally clicked when I set the "JMS Provider" to 'Embedded messaging'. Open the server configuration, go to the 'JMS' tab --> server settings --> JMS Provider section. You will find 3 radio buttons here, by default, the selection is: Disable. Set it to 'Embedded Messaging'. And since you already know how to configure a listener port and attach it to your MDB, there is nothing more for me to explain on that Hopefully, it should work now.