I've been using Tomcat 8's Parallel Deployment as part of a zero-downtime continuous deployment setup for a while now.

When the test gauntlet has been run, the CI server automatically renames the .war file to application##{version-number}.war and copies the war to the /webapp folder. application##333 will coexist nicely with application##332.

The only problem that I'm encountering is that I have to manually undeploy the older applications once all traffic (new sessions) have automatically transitioned to the new one.

Does Tomcat have some built-in mechanism for saying "hey, when this service gets down to zero sessions, it should be removed"? Maybe some sort of "the last session has just expired" event that I can tap into.

If anyone else has automated this kind of application undeploy, I would love to hear about it. Thanks!


You can configure Tomcat to remove the old applications. You need to add the undeployOldVersions attribute to the Host element and set it to true. You'll need to modify your host in server.xml to something like the following:

<Host undeployOldVersions="true" ...>

See the Host documentation for details. In particular, this only works when automatic deployment is enabled.

  • Works beautifully! Thank you so much. – Martin Cron Jan 28 '16 at 18:37
  • Under what version of Tomcat are you running? I have Tomcat 8.5.6 and this does not work. I have enabled FarmWarDeployer, and new releases are automatically deployed. However, after enabled undeployOldVersions on the Host tag, the older war files (and deployments) are not deleted. – Piko May 3 '17 at 18:42
  • Any progress on this with Tomcat 8? – JimmyD Mar 27 '18 at 9:52
  • 1
    The feature is implemented for Tomcat 8. If you are seeing issues when using FarmWarDeployer then open a bug, with steps to reproduce, so it gets looked at. – Mark Thomas Mar 27 '18 at 9:56

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.