tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <>
Subject Re: Populating JNDI entirely in Java code
Date Mon, 01 Apr 2013 19:10:39 GMT
2013/4/1 Benson Margulies <>:
> When embedding Tomcat, I'd like to create some objects purely from code --
> I don't want to bother to express them as XML  -- and then pick them up
> inside webapps. Now, calling enableNaming() on Tomcat sets up a bunch of
> environment, but does not actually create and JNDI objects. If I call
> enableNaming(), and then make JNDI calls before calling start(), should I
> expect that to work?

1. No,

JNDI binds to TCCL (Thread.currentThread().getContextClassLoader()).
Before you call start() the webapp classloader is not initialized and
has not been started. So you cannot bind your JNDI to it.

2. The magic that translates XML into java calls is called Digester
You may start a standalone Tomcat and try to debug it.

The place to look into is
That is the component that translates configuration objects created
when parsing context.xml into JNDI objects.

3. See thread "Register static JNDI env entry dynamically" from 2 weeks ago.

Best regards,
Konstantin Kolinko

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message