tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mindaugas Žakšauskas" <>
Subject JNDI question/problem
Date Mon, 18 Feb 2008 10:40:25 GMT

I'm using Tomcat v5.5.25 with two webbaps deployed as plain files (not
wars). Both of them use JNDI and do some initial binding upon webapp
(context) startup.
The "startup" event is determined by implementing a listener
(javax.servlet.ServletContextListener's contextInitialized method) and
placing it in WEB-INF/web.xml.

Now, there are (at least) two ways of defining/configuring webapp contexts:

1) by having both webapps defined in conf/server.xml, e.g.:

<Server ...>
     <Resource name="foobar" auth="Container" type="java.util.HashMap"

  <Service ...>

     <Context path="" docBase="/path/to/my/webapp1">
        <ResourceLink global="foobar" name="local_foo" type="java.util.Map"/>
     <Context path="" docBase="/path/to/my/webapp2">
        <ResourceLink global="foobar" name="local_bar" type="java.util.Map"/>


2) By having Context part defined separately, e.g. sitting in
conf/Catalina/localhost/webapp1.xml and

Now the difference between the two is that for the (1) case linked
JNDI resource ("java:comp/env/local_bar") is not available upon
startup - I'm getting "javax.naming.NameNotFoundException: Name
local_bar is not bound in this Context". Although when the config sits
separately from server.xml, as in case (2), everything works just fine
and JNDI contains all configured bindings/resource links.

The question is, is this a normal behavior or something that should be
addressed/fixed? Also, is there any bit of JNDI spec which would speak
of JNDI availability upon server/webapp startup?

I would prefer to use the (1) approach as in some cases I need to
specify the order of which webapp starts first while this is not
possible using (2).

Thanks indeed anyone for any ideas, really much appreciated.


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message