tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lorrin Nelson <>
Subject Context problem: java:comp not bound??
Date Thu, 01 May 2003 19:34:10 GMT
Hi all -

I've lost access to my JNDI web app context. I thought unless you 
explicitly set useNaming="false" when defining your Context that you should 
always be able to retrieve java:comp/env. I could until a couple days ago, 
now I can't and after countless hours of searching I'm still clueless. When 
is or isn't java:comp/env accessible from inside a webapp?

If I issue the commands from inside my webapp:
	ctx = new InitialContext();

I get: javax.naming.NameNotFoundException: Name java:comp is not bound in 
this Context

I get the same error trying to get the web app context itself:
	Context envContext = (Context) ctx.lookup ("java:comp/env");

Since the code hasn't really changed and it worked just a few days ago, I 
assume it's a problem with either my server.xml or my web.xml, but for the 
life of me I can't figure out what it is.

I explicitly set the useNaming attribute to true in my <Context> element, 
but it didn't help. I have tried both defining the resources I want to 
access inside the <Context> element and inside the <Server> element. Right 
now they're in the Server element:

server.xml snippet (some <parameter>s clipped out for brevity):

   <!-- Global JNDI resources -->
       <!-- create java:comp/env/jdbc/spw in the InitialContext -->
     <Resource name="jdbc/spw"
        description="Database access for SPW project"/>

     <ResourceParams name="jdbc/spw">

       <!-- MySQL dB username and password for dB connections  -->

       <!-- Class name for mm.mysql JDBC driver -->

       <!-- The JDBC connection url for connecting to your MySQL dB.
	   The autoReconnect=true argument to the url makes sure that the
	   mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
	   connection.  mysqld by default closes idle connections after 8 hours.

Then inside my web.xml webapp element I reference the resource:

     <description>DataSource used for all database access</description>

Besides those three elements in server.xml and web.xml, are there any other 
steps needed to make resources available? I've tried both Tomcat 4.0 and 
4.1, but no luck either way. Thanks!!


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

View raw message