Reputation: 11
The company I work for hosts a few Java web apps. We have production sites and demo sites on the same box. The demo sites are normally copies of what is seen on production, only the resources point to the demo resources (databases and Realm using javax.sql.DataSource). Due to security concerns, appBase is not defined in the webapp directory and is defined elsewhere on the server.
I am in the process of migrating these application from Tomcat 5 to Tomcat 7. The Tomcat 5 server had all of the context defined within the server.xml. It was very convenient as I only need to copy the files to the directories defined by the host, either production host, demo host or both and the context.xml files would be overridden by the server.xml.
The documentation I've read for Tom7 stresses that this type of arrangement, placing the context in the server.xml, is no longer recommended.
What is the best way to set the server up so that I can override the context.xml that is included in the META-INF directory. I want to be able to copy the web app from test (not the jar file) to the correct directory (production or demo) and the server will use either the production database or demo database respectively.
Thanks for your help.
Upvotes: 0
Views: 3992
Reputation: 2030
Usually you have the Project under version-control but you dont like to have the live connection-password/email-smtp-password ... under Version controll.
So you place a context.xml
under version-control at webapp/META-INF/context.xml
with dummy-password like changeme
. Once deployed a webapp with copyXML
-Attribute found in the webapp/META-INF/context.xml
the webapp/META-INF/context.xml
is copied into $TOMCAT_BASE/conf/Catalina/localhost/webapp.xml
if not exists.
So you can change the changeme
password after deployment in $TOMCAT_BASE/conf/Catalina/localhost/webapp.xml
. This way you can be sure theese
To use the TOMCAT_BASE/conf/context.xml
is only for global configuration (if you read the comment in the file):
<!-- The contents of this file will be loaded for each web application -->
Upvotes: 1