tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: Populating JNDI entirely in Java code
Date Mon, 01 Apr 2013 19:10:39 GMT
2013/4/1 Benson Margulies <benson@basistech.com>:
> 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
(http://commons.apache.org/digester)
You may start a standalone Tomcat and try to debug it.
https://wiki.apache.org/tomcat/FAQ/Developing#Debugging

The place to look into is
org.apache.catalina.core.NamingContextListener
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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message