ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » WAS & InitialContext

Post new topic  Reply to topic
 WAS & InitialContext « View previous topic :: View next topic » 
Author Message
janus
PostPosted: Wed May 25, 2005 4:43 am    Post subject: WAS & InitialContext Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Wed May 25, 2005 5:11 am    Post subject: Reply with quote

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
View user's profile Send private message
janus
PostPosted: Wed May 25, 2005 10:20 am    Post subject: Reply with quote

Newbie

Joined: 25 May 2005
Posts: 5

Both! Can you give me examples of both solutions?
Thanks!
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed May 25, 2005 10:23 am    Post subject: Reply with quote

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
View user's profile Send private message
janus
PostPosted: Thu May 26, 2005 4:23 am    Post subject: Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Thu May 26, 2005 4:30 am    Post subject: Reply with quote

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
View user's profile Send private message
janus
PostPosted: Thu May 26, 2005 4:45 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Thu May 26, 2005 8:07 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Henry
PostPosted: Mon Jun 06, 2005 5:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Tue Jun 07, 2005 3:49 am    Post subject: Reply with quote

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
View user's profile Send private message
janus
PostPosted: Tue Jun 07, 2005 4:06 am    Post subject: jar Reply with quote

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
View user's profile Send private message
bower5932
PostPosted: Tue Jun 07, 2005 6:07 am    Post subject: Re: jar Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
fjb_saper
PostPosted: Tue Jun 07, 2005 12:36 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » WAS & InitialContext
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.