Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Right now, all application-specific configuration is done in conf/Catalina/localhost/myWebApp.xml, and this file changes between different deployment scenarios (test/production/personal, etc). My initial thought was to create multiple configuration files named for the explicit configuration. Ideally, these deployment-specific configuration files would be interchangeable. That is, a switch of a configuration file containing parameters that change between deployments would be the only configuration change needed to switch a deployment.

What's the best way to go about doing this? Can I override properties with tomcat? How can I use more than one configuration file for a webapp context? If I can override, how do I specify override precedence?

Thanks.

share|improve this question
    
Are you talking about different stages for one application or different tomcat instances for different applications? –  Christian Jan 8 '10 at 21:17

2 Answers 2

From the core server end, you can pass in the Tomcat configs itself at startup instead of it using the defaults, like so:

cd $TOMCAT_HOME
./bin/startup.sh -config /some/path/to/server.xml

This server.xml defines your 'host' element for the webapps which has several properties as to how they are deployed (take a look at the default one). The config docs are here:

http://tomcat.apache.org/tomcat-6.0-doc/config/host.html

Take a look a little further down in that doc for where it starts talking about "Automatic Application Deployment" -- there's some verbiage that starts talking about different XML files. Perhaps one of these defined procedures the engine has will allow create a working scenario for your needs; I've not done exactly as you request though, typically a WAR is deployed that contains it's own XML and is auto-unpacked - I don't mess with overwriting post-unpacked files in the webapps/foo/ areas.

share|improve this answer
up vote 0 down vote accepted

The best thing you can do, apparently, is to build a variable parsing engine that creates multiple deployment files for the different deployments you need.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.