The moose likes Tomcat and the fly likes More one context.xml in a Webapp Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Products » Tomcat
Reply Bookmark "More one context.xml in a Webapp" Watch "More one context.xml in a Webapp" New topic
Author

More one context.xml in a Webapp

Enrico Oliosi
Greenhorn

Joined: Aug 26, 2010
Posts: 10

I use a context.xml file to set jndi resources for a webapp. I have a question.

Suppose I set resources for the webapp in the context.xml file in $CATALINA_HOME/conf/.

Then I put resources in the <CONTEXTPATH>.xml file and copy the file in
$CATALINA_HOME/conf/[enginename]/[hostname]/.

Finally I deploy my webapp and this webapp has a file context.xml in /META-INF dir.

Which of three files is read by Tomcat?


Enrico Oliosi
Greenhorn

Joined: Aug 26, 2010
Posts: 10
Mybe I have found a solution:

from this mailing list I read "If a <contextpath>.xml exists,
it always takes priority over anything in a WAR or an exploded directory."

If you are interesting about other informations I suggest you to read: Tomcat Configuration Reference

This message was edited 1 time. Last update was at by Enrico Oliosi

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 11740

Here's the priorities, from low to high:

1. META-INF/context.xml in a WAR file
2. META-INF/context.xml in webapps/xxx (WAR) directory
3. conf/Catalina/localhost/xxx.xml (Context file) where "localhost" is replaced by alternative hostnames for more complex server setups.
4. DON'T put a context in server.xml!

An exploded WAR takes priority over a WAR file, even if the WAR file is newer. A characteristic of Tomcat that's caused me grief more than once, since it also means that a replacement WAR won't be exploded to take the place of an older exploded WAR.


A lot the of modern-day software development platforms are designed to permit parcelling out work to those with the best aptitude for it. A lot of modern-day business is predicated on making one person do all the work, regardless of aptitude.
Enrico Oliosi
Greenhorn

Joined: Aug 26, 2010
Posts: 10

Thanks Tim for your answer
 
 
subject: More one context.xml in a Webapp
 
MyEclipse, The Clear Choice