Keep context-configuration when redeploying via Cargo

Posted by Björn Pollex on Server Fault See other posts from Server Fault or by Björn Pollex
Published on 2012-11-26T09:08:41Z Indexed on 2012/11/26 17:07 UTC
Read the original article Hit count: 388

Filed under:

I am using Tomcat 7 to host a web-application that requires a JNDI datasource to be set up. Because this resource is specific to this application, I would like to configure it inside the application-specific context-descriptor in $CATALINA_BASE/conf/[enginename]/[hostname]/. I am also using Cargo from Maven to deploy the web-application to Tomcat.

The problem is that when I do a redeploy with Cargo, it first undeploys the application, before deploying it again. When undeploying it, Tomcat deletes the context-descriptor of the application, so it won't work after redeploying.

I could of course package the context-descriptor with the application, but I would like to keep any such container-specifics out of the .war. Another alternative is to configure the datasource in the global context-descriptor, but that too seems wrong, because the datasource is supposed to be exclusive to my application.

Is my approach fundamentally wrong? What is the best practice here? Is there any way to prevent Tomcat from deleting the descriptor when undeploying?

© Server Fault or respective owner

Related posts about tomcat