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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]