Qiwen Gao
Qiwen Gao

Reputation: 63

How to update a .war in Tomcat

I am new to Tomcat and following is the steps I am using to update a .war in Tomcat:

  1. stop tomcat.
  2. delete .war and the folder with same name in /webapps.
  3. copy and paste my new .war in /webapps.
  4. restart tomcat by ./bin/catalina.sh run.

However, the new .war always won't work. Seems it's the old version .war that is running.

In /conf/server.xml, I am using the following configs:

  <Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">

Can someone help me on this problem? Thanks!

Upvotes: 6

Views: 13572

Answers (2)

Diyarbakir
Diyarbakir

Reputation: 2089

Replacing the old war file with a new one should work fine. You don't need to delete the old one, just overwrite it.

If you don't want to restart the server you could set <Context reloadable="true"> in context.xml file.

Better yet, I'd suggest you use Tomcat Manager to deploy without shutting down Tomcat. Hope this helps.

Upvotes: 10

Crusaderpyro
Crusaderpyro

Reputation: 2242

What I usually do is go to the tomcat admin page (e.g. http://localhost:8080/) (assuming port is 8080 and the tomcat is hosted on the same server). Click on 'Manager App'. Scroll below and you would see a section 'War file to Deploy'. Browse the war file and click on 'Deploy'.

Note: Credentials will be asked when you click on 'Manager App' button. In this case check the conf/tomcat-users.xml file and make the following entry within <tomcat-users> element:

<user username="admin" password="admin" roles="manager-gui" />

After this you can login with admin/admin.

Upvotes: 1

Related Questions