This content has been marked as final.
Show 2 replies
-
1. Re: Creating a JNDI binding from a servlet?
peterj May 11, 2006 12:20 PM (in response to ljnelson)The following works for me:
Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.PROVIDER_URL, "localhost:1099"); Context ctx = new InitialContext(env);
I do agree with your comment that the server should give you the local JNDI tree is you don't give any properties. -
2. Re: Creating a JNDI binding from a servlet?
ljnelson May 11, 2006 12:45 PM (in response to ljnelson)Thanks, Peter; I know I can get away with that. You can actually get away with quite a bit less:
final InitialContext ic = new InitialContext(new Hashtable() { { this.put(Context.PROVIDER_URL, "localhost"); } });
...if everything has been set up for the defaults.
It looks like the answer may very well be no, if you are a servlet trying to bind something then you are a client like any other client, and you must therefore somehow specify what JNDI server to attach to. This makes a certain amount of sense; I was just hoping for, say, a jndi.properties that got put somewhere when a given EAR/WAR/whatever (or when the JBossNS system itself gets deployed) saying what port it's on, what host it thinks it's on, etc.).
Thanks again,
Laird