I'm trying to lookup an JNDI environment entry from a JSP page, but it
doesn't work.
I have this in my web.xml file:
<env-entry>
<description>Foo entry</description>
<env-entry-name>Foo</env-entry-name>
<env-entry-value>the Foo value</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
And my JSP page looks like this:
<%@page import="casino.jsputils.*" %>
<% javax.naming.Context ctx = new javax.naming.InitialContext(); %>
<html>
<head>
<title>JNDI test</title>
</head>
<body>
<h1>JNDI test</h1>
<p>JNDI lookup of <code>java:comp/env/Foo</code> gives
<code><%= ctx.lookup("java:comp/env/Foo") %></code>
</body>
</html>
When I try to access this JSP page, I get the following error message:
500 Internal Server Error
javax.naming.NamingException: Error instantiating web-app JNDI-context:
Value not set
at com.evermind.server.http.HttpApplication.getEnvironmentContext(JAX)
at com.evermind.server.hm.f4(JAX)
at com.evermind.server.hm.lookup(JAX)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at /jnditest.jsp._jspService(/jnditest.jsp.java:31) (JSP page line 13)
at com.orionserver.http.OrionHttpJspPage.service(JAX)
at com.evermind.server.http.HttpApplication.xj(JAX)
at com.evermind.server.http.JSPServlet.service(JAX)
at com.evermind.server.http.d3.sw(JAX)
at com.evermind.server.http.d3.su(JAX)
at com.evermind.server.http.ef.s1(JAX)
at com.evermind.server.http.ef.do(JAX)
at com.evermind.util.f.run(JAX)