How to overwrite war files during Tomcat hot deployment?

10,260

Solution 1

With Tomcat 7, the task of updating wars without taking down the tomcat is easier. There are multiple ways to do this.

I would suggest you to follow either one of the below:

  1. Use Tomcat Manager GUI
  2. Using ANT based Deployment using Tomcat's Deploy task.

In any of these cases, you would need to rename your war file, from adweb.war to adweb##.war, and context.xml (if needed) and upload to a remote/local tomcat setup.

Everytime you need to upgrade your war, just use a higher version number than the previous one while renaming the war file.

Note that, the context path /adweb should also be updated as /adweb## while performing hot deployment.

Once, the new version is successfully deployed (indicated in the manager UI), you can stop/undeploy the previous version. If not, the tomcat will still use the latest version and all the new requests will be redirected to the new version.

Solution 2

My answer is not perfect but it can be used as a way around. While your tomcat is running delete the existing war file and then paste your current war file and after few seconds you can see on the console that your war has been deployed.

Hope this helps

Share:
10,260
Ree
Author by

Ree

Updated on June 14, 2022

Comments

  • Ree
    Ree almost 2 years

    I am using Tomcat 7.0 for my web application deployment ... Still now i used to stop the server and delete the old war file and paste the new war file and then start the server ... Now I heard about hot deployment service and willing to do hot deployment for my website ... I searched various questions in stack overflow and tried according to the answers but its not working .. I have a war file as adweb.war and made some updates and produce the same adweb.war to be overwritten in the WebApps folder ... How can I do that ? Pls answer in simple steps so that I can easily understand .. Pls dont mark this as duplicate because I wrote this question as there is insufficient answers in this topic and some answers are there which are very complicated to understand for beginners like me . So I hope this question will help beginners like me ...