Hello. I am seeking some advice for the best ways to deploy Java web applications to different Tomcat environments.

In particular, my application requires that a JNDI resource be defined for a database, where the database server address and credentials will vary depending on the environment the application is deployed to.

* Tomcat: 8.0.36
* OS: varies depending on the environment deployed to

If I include in the WAR file, a META-INF/context.xml that includes the Resource element, Tomcat will use that to create the file:
$CATALINA_HOME/conf/engine/host/my-application.xml

The context file my-application.xml can then be modified so that the Resource settings are appropriate for the environment.

However, if, for any reason, the application is undeployed and then re-deployed, my-application.xml will be recreated with the settings as they originally appeared in the WAR file.

The options that seem evident to me are:

1) Create a different WAR file for each environment. This strikes me as a bit onerous.

2) Use environment variables in my-application.xml such as: url="${databaseurl}" and then define those environment variables using the Environment element in the GlobalNamingResources of Tomcat's server.xml.

Regarding #2, would it be possible to instead use a properties file to define the variables? I assume adding entries to catalina.properties would work, but is it possible to define a properties file separate from catalina.properties which deals more with system properties rather than application properties?

I haven't been able to find a documented standard methodology for Tomcat deployments to different environments, but I'm certain there must be some common and elegant ways of doing this. I'm interested in hearing what others have done.

Thank you,
Philip

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to