tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Monsorno <li...@exolution.de>
Subject JNDI-lookup fails with GlobalResources
Date Fri, 14 Nov 2003 10:47:15 GMT
Hi *,

I recently installed tomcat 4.1.29 and deployed a web application on
it via a war-file.  The provided server.xml contains the following
lines: 

,----
|    ...
|   <!-- Global JNDI resources -->
|   <GlobalNamingResources>
| 
|     <!-- Test entry for demonstration purposes -->
|     <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
| 
|   ...
`----

My application tries to read this value through a JNDI lookup with
this code:

,----
|     LOG.debug("testing jndi lookup ...");
|     try {
|       Context initCtx = new InitialContext();
|       Context envCtx = (Context) initCtx.lookup("java:comp/env");
| 
|       String jndikey = "simpleValue";
| 
|       LOG.debug("envCtx.lookup(\""+jndikey+"\")="+envCtx.lookup(jndikey));
|     } catch (NamingException exc) {
|       LOG.warn("cannot init from JNDI context", exc);
|     }
|     LOG.debug("jndi test end.");
`----

which leads to the log output:

,----
|   2003-11-14 10:33:06,237 DEBUG (myapp.InitializationServlet.testJNDI(InitializationServlet.java:67))
- testing jndi lookup ...
|   2003-11-14 10:33:06,245 WARN  (myapp.InitializationServlet.testJNDI(InitializationServlet.java:76))
- cannot init from JNDI context
|   javax.naming.NameNotFoundException: Name simpleValue is not bound in this Context
| 	  at org.apache.naming.NamingContext.lookup(NamingContext.java:811)
| 	  at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
| 	  at myapp.InitializationServlet.testJNDI(InitializationServlet.java:74)
| 	  at myapp.InitializationServlet.init(InitializationServlet.java:29)
|   ...
`----

So obviously, putting values into JNDI context fails.  (If I set the
value in web.xml instead as an <env-entry>, everything goes well.)

Have I forgotten to do some additional initialization or configuration
or something else?  Any ideas?

Thanks in advance,

Martin.



-- 
Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message