0

I have a WAR that I've set as the default web app in Tomcat's server.xml:

Inside Server.xml

<Host...>
    <Context docBase="mywar" path="" />

In addition, I have a META-INF/context.xml file where I set an environment variable.

<?xml version="1.0" encoding="utf-8"?>
<Context debug="0" reloadable="true">
    <Environment
            name="my.name"
            type="java.lang.String"
            value="donrhummy"
    />
</Context> 

But it's throwing an exception javax.naming.NameNotFoundException: Name my.name is not bound in this Context.

How can I get that context variable in my app?

NOTE: That variable exists when I go to http://localhost/mywar

Don Rhummy
  • 24,730
  • 42
  • 175
  • 330

1 Answers1

0

The only solution i could find was:

  1. Rename my WAR as ROOT.war (Case-sensitive)
  2. Remove the <Context...> from server.xml

Tomcat will treat that as the root WAR (i.e. for the "/" path) and let it use the context form it's own META-INF directory.

Don Rhummy
  • 24,730
  • 42
  • 175
  • 330