Try writing some simple stand-alone java client code and see if that can get
an initial context.  THat will tell you if the problem is with tomcat or
with jndi.  In my experience port number is not necessary, at least when
everyone is using the default port.  So long as provider.url is the ip for
the machine that jboss is running on you OUGHT to be good.  If deployment
works with in-VM tomcat, that should mean that jndi is running, but who can
be sure...

> -----Original Message-----
> From: Anatoly Akkerman [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, February 25, 2001 7:14 PM
> To: JBoss-User
> Subject: Re: [jBoss-User] How to setup JNDI in stand-alone TomCat not
> started as MBean?
> 
> 
> 
> On Sun, 25 Feb 2001, Steve Salkin wrote:
> 
> > > 
> > > Of course, I had it set to 
> > > 
> > > 1. other machine's hostname
> > > 2. IP address
> > > 3. the above with the port number.
> > > 
> > > Then I tried the same thing on the same machine where 
> JBoss is running and
> > > used localhost there, to no avail. 
> > 
> > OK, you're probably thinking that I'm an idiot, or that I 
> think you are, but
> > I had to ask :)
> 
> It's OK. 
> 
> I've tried many things. Here is a code snippet
>       /*
>          Hashtable env = new Hashtable();
>          env.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.jnp.interfaces.NamingContextFactory");
>          env.put(Context.PROVIDER_URL, "localhost:1099");
>          System.out.println ("Trying to get InitialContext");
>          Context context = new InitialContext(env);
>       */
>          System.setProperty("java.naming.factory.initial",
> "org.jnp.interfaces.NamingContextFactory");
>          System.setProperty("java.naming.provider.url",
> "localhost:1099");
> 
>          Context context = new InitialContext();
>          System.out.println ("Created new InitialContext");
> 
>          System.out.println ("Looking up Context");
>          context = (Context) context.lookup("java:comp");
> 
> this is a part of JbossWebXmlReader class, a Request Interceptor for
> TomCat that reads web.xml and jboss-web.xml from WAR's 
> META-INF directory
> and exports appropriate environment entries to JNDI.
> 
> Indeed, it seems that jndi.properties is not picked up 
> properly, so I set
> the properties in the code.
> 
> I've done what you've recommended -- the property gets set 
> and the call to
> new InitialContext() just hangs.
> 
> If you remove all the setup of properties or the environment, then
> InitialContext() gets created but lookup of "java:comp" fails 
> saying that
> the naming factory is not setup or something of that sort.
> 
> So, I am pretty sure that the setting are getting picked up, it seems,
> though that JNDI hangs in trying to establish a connection? JBoss is
> running and the naming server reports that it is running on port 1099.
> 
> If this helps in any way, here is another mystery. If I modify
> jndi.properties in jboss/conf/default and uncomment
> java.naming.provider.url=localhost entry, JBoss hangs as well 
> on JBossMQ
> startup. 
> 
> 
> 
> 
> > 
> > Maybe the next thing is to instrument the code with a bit 
> of debugging. For
> > one thing, maybe just before the getInitialContext() call print out
> > System.getProperty("java.naming.factory.initial") and
> > System.getProperty("java.naming.provider.url")
> > to make sure that your jndi.properties is indeed getting 
> picked up and
> > not just masking your earlier problem in some other way.
> > 
> > I think something must be wrong in there if this doesn't 
> work on the same
> > box.
> > 
> > S-
> > 
> > 
> > 
> > --
> > --------------------------------------------------------------
> > To subscribe:        [EMAIL PROTECTED]
> > To unsubscribe:      [EMAIL PROTECTED]
> > List Help?:          [EMAIL PROTECTED]
> > 
> > 
> 
> 
> 
> --
> --------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> List Help?:          [EMAIL PROTECTED]
> 





---------------------------------------------------------------------
This message (including any attachments) contains confidential, proprietary
or privileged information intended for a specific purpose and individual(s),
and is protected by law.  If you receive this message in error, please
immediately delete it and all copies of it from your system, destroy any
hard copies of it and notify the sender.  Any unauthorized disclosure,
copying or distribution of any part of this message, or the taking of any
unauthorized action based on it, is strictly prohibited.


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
List Help?:          [EMAIL PROTECTED]

Reply via email to