C
Chris McMahon
I'm having trouble getting an Environment parameter to work through the
server.xml file of Tomcat 5.5.
My server.xml file looks like this:
<Server port="8005" shutdown="SHUTDOWN">
...
<Service name="Catalina">
...
<Engine name="Catalina" defaultHost="localhost">
...
<Host
name="localhost"
appBase="C:/Development/Tomcat/deployment/tomcat5.5/webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<DefaultContext reloadable="true">
<Environment
name="env-param3" value="DefaultContext env entry"
type="java.lang.String" override="false"/>
</DefaultContext>
<Realm className="org.apache.catalina.realm.MemoryRealm"
debug="0" digest="SHA"
pathname="conf/unleashed-users.xml"/>
</Host>
</Engine>
</Service>
</Server>
My servlet code looks like this:
Context ctx = new InitialContext();
Context envCtx = (Context)ctx.lookup( "java:comp/env" );
out.println( envCtx.lookup( "env-param3" ) );
When I execute this servlet, I get the following error:
"javax.naming.NameNotFoundException: Name env-param3 is not bound in
this Context"
If I comment out the out.println(), it runs fine. Any ideas what I'm
doing wrong?
server.xml file of Tomcat 5.5.
My server.xml file looks like this:
<Server port="8005" shutdown="SHUTDOWN">
...
<Service name="Catalina">
...
<Engine name="Catalina" defaultHost="localhost">
...
<Host
name="localhost"
appBase="C:/Development/Tomcat/deployment/tomcat5.5/webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<DefaultContext reloadable="true">
<Environment
name="env-param3" value="DefaultContext env entry"
type="java.lang.String" override="false"/>
</DefaultContext>
<Realm className="org.apache.catalina.realm.MemoryRealm"
debug="0" digest="SHA"
pathname="conf/unleashed-users.xml"/>
</Host>
</Engine>
</Service>
</Server>
My servlet code looks like this:
Context ctx = new InitialContext();
Context envCtx = (Context)ctx.lookup( "java:comp/env" );
out.println( envCtx.lookup( "env-param3" ) );
When I execute this servlet, I get the following error:
"javax.naming.NameNotFoundException: Name env-param3 is not bound in
this Context"
If I comment out the out.println(), it runs fine. Any ideas what I'm
doing wrong?