I have two webApps FOO and BAR which I want to deploy on the same Tomcat 8 instance. Both weppApps should have their own context configuration for JNDI purposes. Also both webApps should be able to autodeploy when a new WAR file is transferred over FTP (continuous integration).
What I have working:
One webApp, with context and autodeploy
- context defined in context.xml
Two webApps, each their own context but no autodeploy
- context is defined in $CATALINA_BASE/conf/[enginename]/[hostname]
- OR context is defined in server.xml
The problem with two webApps is that Tomcat always tries to remove the custom context configuration when the current deployed WAR is being undeployed. Thus losing the JNDI configuration.
When the context is defined in "$CATALINA_BASE/conf/[enginename]/[hostname]" the context is removed.
When the context is defined in "server.xml" an error is thrown that tomcat cannot remove the context because it is defined in "server.xml".
How can I stop Tomcat from trying to delete context files during undeploy?
I have tried playing with autoDeploy="false", deployXML="false" and autodeploy='false" without success.
One possible solution should be defining the context inside the WAR file. However I think defining environment related configuration files in a WAR is a NO-GO and asking for mistakes in the future.
Some older posts mark this problem as 'by design' but that's just silly.
related posts:
https://serverfault.com/questions/192784/why-does-tomcat-like-deleting-my-context-xml-file
Jenkins Tomcat deploy : Context is defined in server.xml and may not be undeployed