Tomcat 7 has a feature called parallel deployments. Using this feature it is possible to have multiple instances of your app running under the same context path.
This blog post explains it nicely: http://www.javacodegeeks.com/2011/06/zero-downtime-deployment-and-rollback.html
To sum it up you need to manually version your wars when you add them to your appBase.
cp foo##001.war apache-tomcat-7/webapps/
cp foo##002.war apache-tomcat-7/webapps/
You may want to set undeployOldVersions
and autoDeploy
to true so that tomcat automatically deploys the app and removes the old version if it is no longer necessary.
Check https://tomcat.apache.org/tomcat-7.0-doc/config/host.html for further info on tomcat's config.
The Version after the ## must be string comparable, so you can use e.g. a build number from your CI System but you may have to zero pad it.
There are a few things to look out for:
- External resources need to be shareable, if you are using a database but your new versions needs a new schema you'll run into problems. Or if you open a TCP listener on a specific port it is also not shareable.
- Caches, if your application uses internal caches they should be write through and expire quickly
- The app must be undeployable