Author |
Message
|
rajess_kr |
Posted: Thu Mar 18, 2010 10:50 am Post subject: creating standalone jms client which runs outside of WAS 6.1 |
|
|
Newbie
Joined: 26 Feb 2010 Posts: 8
|
hi,
i want to create a standalone jms client application which runs in a standard java runtime env outside of a J2EE / WAS application server.
i have already written a standalone jms client which uses "com.ibm.websphere.naming.WsnInitialContextFactory" and jmsURL as ""iiop://IP Address:2809""
my jndi code is as shown below:-
//Connect to JNDI namespace.
Hashtable environment = new Hashtable() ;
environment.put(Context. INITIAL_CONTEXT_FACTORY, jmsICF) ;
environment.put(Context. PROVIDER_URL, jmsURL);
Context ctx = new InitialContext(environment);
when i try to connect to JNDI resource on WAS server from withing my standalone java application, it always gives the below exception.
lassDefFoundError: com/ibm/ejs/ras/Tr
at com.ibm.websphere.naming.WsnInitialContextFactory.<clinit>(WsnInitialContextFactory.java:6
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at JMSTest.main(JMSTest.java:27)
Caused by: java.lang.ClassNotFoundException: com.ibm.ejs.ras.Tr
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 9 more
I have added the following JAR files in my classpath:-
fscontext.jar
jndi.jar
providerutil.jar
jms.jar
naming.jar
namingclient.jar
namingserver.jar
and all the libraries from WAS Server "appserver\java\lib" folder.
My queries:-
1) which JAR files are required in order to connect to JNDI resources on WAS outside of J2EE or WAS container?
2) What could be the reason for the above exception?
thks in advance |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Mar 18, 2010 10:52 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You need all jars in <mqinstall>java/lib  _________________ MQ & Broker admin |
|
Back to top |
|
 |
rajess_kr |
Posted: Thu Mar 18, 2010 11:23 am Post subject: creating standalone jms client which runs outside of WAS 6.1 |
|
|
Newbie
Joined: 26 Feb 2010 Posts: 8
|
when you say "<mqinstall>java/lib"
are you referring to IBM MQ Server or the Websphere Application Server?
i added the following jars in my application,
com.ibm.mq.jar
com.ibm.mqbind.jar
com.ibm.mqjms.jar
connector.jar
ecutils.jar
ffdc.jar
fscontext.jar
ibmorb.jar
idl.jar
iwsorb.jar
jms.jar
jndi.jar
jta.jar
ldap.jar
lmproxy.jar
naming.jar
namingclient.jar
ras.jar
rmm.jar
sas.jar
utils.jar
wsexception.jar
however im now getting the below error dont know what is the reason now?
Exception in thread "main" java.lang.NoClassDefFoundError: com/ibm/ws/security/util/AccessController
at com.ibm.ejs.ras.RasHelper.getSystemProperty(RasHelper.java:686)
at com.ibm.ejs.ras.Tr.processTraceSettings(Tr.java:1194)
at com.ibm.ejs.ras.Tr.<clinit>(Tr.java:223)
at com.ibm.websphere.naming.WsnInitialContextFactory.<clinit>(WsnInitialContextFactory.java:6
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at JMSTest.main(JMSTest.java:2 |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Mar 18, 2010 11:24 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
fjb_saper wrote: |
You need all jars in <mqinstall>java/lib  |
That won't help at all with establishing a connection to the WAS JNDI or the SiBus messaging that rajess_kr is trying to do.
rajess_kr should go back to the *WAS* documentation and find out about "application clients". |
|
Back to top |
|
 |
rajess_kr |
Posted: Thu Mar 18, 2010 11:40 am Post subject: |
|
|
Newbie
Joined: 26 Feb 2010 Posts: 8
|
hi,
what i want to achieve is to be able to develop a JMS client and still leverage the JNDI resources defined in WAS 6.1 Application Server for QueueConnectionFactories, and Queues.
If this can be done, i can develop my JMS client independently as a standalone java application and then be able to export it as a reusable JAR file which can then be used in a Web Application Deployed on WAS.
The basic idea is to keep the business logic functions in a standalone jms java application for all backend integration with MQ using JMS.
The basic approach that i am taking is as below:-
Develop a JMS client and package it in a jar file.
This JMS client outside of WAS can leverage the JNDI configurations defined in WAS.
hope this is clear
thks. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Mar 18, 2010 8:31 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
rajess_kr wrote: |
hi,
what i want to achieve is to be able to develop a JMS client and still leverage the JNDI resources defined in WAS 6.1 Application Server for QueueConnectionFactories, and Queues.
If this can be done, i can develop my JMS client independently as a standalone java application and then be able to export it as a reusable JAR file which can then be used in a Web Application Deployed on WAS.
The basic idea is to keep the business logic functions in a standalone jms java application for all backend integration with MQ using JMS.
The basic approach that i am taking is as below:-
Develop a JMS client and package it in a jar file.
This JMS client outside of WAS can leverage the JNDI configurations defined in WAS.
hope this is clear
thks. |
As Jeff said, ideally for that you need a J2EE client. The WAS footprint for such is not the smallest.
If you are willing to forgo a little change (like JNDI initialization and use instead the file based JNDI) all the rest of your code may stay more or less the same.
Be wary however that WAS will enforce a little bit of difference in transaction handling. If the MQ session participates in a global transaction that (global) transaction is enforced. This too may slightly change your standalone code.
About the <MQInstall path> I was referring to the install path on a box with either MQ Client or MQServer installed.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|