Jaikiran Pai wrote:Based on this documentation, all you have to do is package a META-INF/context.xml in your .war file with the following contents:
The docBase will be inferred by default (based on the .war file name). And you don't even have to edit the global server.xml.
Yup. Or you can supply an external context file (in TOMCAT_HOME/conf/Catalina/localhost) that can provide the context and allow you to switch versions by simply changing the name of the codebase WAR file in that context file. Or you can deply using the
Tomcat manager or similar deployment tool (which will create a context file for you).
I also like to put a "version.txt" file in my WARs to ensure that I can query the webapp and see if I'm running the version I think I'm running.
One caution, however. When redeploying, it's a good idea to remove the old contents of TOMCAT_HOME/work/Catalina/localhost and any exploded WARs from TOMCAT_HOME/webapps. Otherwise you can end up with stale code and resources.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.