Author |
Message
|
janus |
Posted: Wed May 25, 2005 4:43 am Post subject: WAS & InitialContext |
|
|
Newbie
Joined: 25 May 2005 Posts: 5
|
I have a MQ JMS provider in WAS and writing JMS code to connect to it.
I'm having trouble to create InitialContext.
What should the values of PROVIDER_URL and INITIAL_CONTEXT_FACTORY be for WAS MQ JMS provider ?
Hashtable env = new Hashtable();
env.put(Context.PROVIDER_URL, PROVIDER_URL);
env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY));
Context jndiContext = new InitialContext(env);
Thanks,
janus |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed May 25, 2005 5:11 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
This is documented in the Using Java manual - Chapter 5 Using the JMS Administration tool - Configuration section.
Are you writing a J2EE Application Client, or a standalone J2EE app? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
janus |
Posted: Wed May 25, 2005 10:20 am Post subject: |
|
|
Newbie
Joined: 25 May 2005 Posts: 5
|
Both! Can you give me examples of both solutions?
Thanks! |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed May 25, 2005 10:23 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
janus wrote: |
Both! Can you give me examples of both solutions?
Thanks! |
The information you're asking for doesn't change, and is still directly addressed in the section of the Using Java manual I pointed you at.
The only reason I asked is - at least with an AppClient, you should look up a Resource Environment Reference, rather than a Resource Reference - to ensure that you get the object on the server JNDI rather than an object in a local JNDI repository. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
janus |
Posted: Thu May 26, 2005 4:23 am Post subject: |
|
|
Newbie
Joined: 25 May 2005 Posts: 5
|
One more question
In which WAS JAR is
com.ibm.websphere.naming.WsnInitialContextFactory
class located? |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu May 26, 2005 4:30 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
janus wrote: |
One more question
In which WAS JAR is
com.ibm.websphere.naming.WsnInitialContextFactory
class located? |
I don't know.
BUT! I remember a big long thread about just such a thing, and how much trouble someone was having. So try searching for WsnInitialContextFactory or some such and see what you can find.
I think your best bet is to actually install a WAS App Client on the machine - as I recall there was more than one jar file and some native libraries that were needed... _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
janus |
Posted: Thu May 26, 2005 4:45 am Post subject: |
|
|
Newbie
Joined: 25 May 2005 Posts: 5
|
Actually, I have WAS AppServer installed on the same machine. I still get:
Could not create JNDI API context: javax.naming.NoInitialContextException: Cannot instantiate class: c
om.ibm.websphere.naming.WsnInitialContextFactory [Root exception is java.lang.ClassNotFoundException: com.ibm.websphere.
naming.WsnInitialContextFactory]
although I have all WAS jars on my classpath...
Doesn't anyone know where that jar is...`?
Thanks,
janus |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu May 26, 2005 8:07 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Janus
I have been struggling myself a bit trying to make it work.
The skinny of it is that you need to search for a file named
launchclient.bat or .sh depending on your env.
A HUGE Thanks to Jeff for showing me the way...
The WAS J2EE client seems to be quite heavyweight and not to really work outside of the WAS machine as you would need nearly all the files anyway....
However I would first check if your environment references are setup right. Use the JNDI Explorer (from the Test Client Wsad).
This should show you whether you are going to be able to access any of the lookups the way you think.
Enjoy  |
|
Back to top |
|
 |
Henry |
Posted: Mon Jun 06, 2005 5:51 pm Post subject: |
|
|
Acolyte
Joined: 08 Oct 2003 Posts: 73
|
I am a newbie on JMS development.
I had put what mentioned by Janus
Hashtable env = new Hashtable();
env.put(Context.PROVIDER_URL, PROVIDER_URL);
env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY));
Context jndiContext = new InitialContext(env);
I had set the Initial context factory using WsnInitialContextFactory. However, when I tried to exeute the code. It prompted out with the following error
java.lang.NoClassDefFoundError: org/omg/CosTransactions/InvalidControl
at com.ibm.websphere.naming.WsnInitialContextFactory.getInitialContext(WsnInitialContextFactory.java:72)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:255)
at javax.naming.InitialContext.init(InitialContext.java:231)
at javax.naming.InitialContext.<init>(InitialContext.java:207)
May I know when can I get the jar file for the Invalid Control class? |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jun 07, 2005 3:49 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
jefflowrey wrote: |
BUT! I remember a big long thread about just such a thing, and how much trouble someone was having. So try searching for WsnInitialContextFactory or some such and see what you can find. |
_________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
janus |
Posted: Tue Jun 07, 2005 4:06 am Post subject: jar |
|
|
Newbie
Joined: 25 May 2005 Posts: 5
|
I found WsnInitialContextFactory in naming.jar, but then it fails with some other class missing.... |
|
Back to top |
|
 |
bower5932 |
Posted: Tue Jun 07, 2005 6:07 am Post subject: Re: jar |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
janus wrote: |
I found WsnInitialContextFactory in naming.jar, but then it fails with some other class missing.... |
and that class would be? |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Jun 07, 2005 12:36 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Read my earlier post ...
This is exactly the trouble I was having. If you want to tap into the WAS JMS context you need to start a J2EE Client ... see the start files and set the full classpath and context i.e. nearly load all the WAS jars.....
Not worth the trouble for me .... so I just created a file context for the clients....
Enjoy |
|
Back to top |
|
 |
|