3

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

https://github.com/psi-probe/psi-probe/issues/374

G-J
  • 401
  • 7
  • 17
  • It can be achieved very easily using Pivotal server, it will let you create n number of instances from the same tomcat binary plus many value added services. You can create two nio-instances. No need to change a single line of your application code. – TruckDriver Aug 02 '17 at 09:08
  • Thanks for the tip! However changing the underlying infrastructure sw seems a bit drastic for now. – G-J Aug 02 '17 at 12:19

0 Answers0