Tomcat 5.5 Environment parameter

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top