David W.
David W.

Reputation: 107040

Tomcat Deployment - How does Tomcat detect Changes in war?

We have a tomcat deployment where we're deploying a war called app.war. In the /opt/tomcat/webapps directory you see:

/opt/tomcat/webapps/foo.war
/opt/tomcat/webapps/foo
/opt/tomcat/webapps/host-manager
/opt/tomcat/webapps/jmx-console
...

You can see that Tomcat deployed foo.war into the foo directory.

I thought if we put a new foo.war in the webapps directory, Tomcat checks to see if this was changed, remove the old foo directory, and unwar foo.war into foo.

We have an automated deployment script that failed, the deployment script shutdown Tomcat, copied foo.war to /opt/tomcat/webapps and restarted Tomcat. However, Tomcat never replaced the /opt/tomcat/webapps/foo directory with the contents of the new foo.war. Manually deleting /opt/tomcat/webapps/foo allowed Tomcat to create a new foo directory with all of the new files in it.

The deployment script was suppose to delete /opt/tomcatwebapps/foo but due to an error in the script that didn't happen. We've now fixed the bug. However, the script had been used before in deployments, and we never had this issue, so I assume that Tomcat was able to detect the changes ands deploy the new foo.war.

So, does Tomcat detect when a war file was changed. If so, how does it do this? The deployment script touches the war file to update the timestamp to help in this detection, so it couldn't be a timestamp issue.

Upvotes: 1

Views: 2688

Answers (1)

tshenolo
tshenolo

Reputation: 463

If you copy foo.war into webapps tomcat will redeploy your application. Check catalina.out for logs.

Do not shutdown Tomcat before deployment. Modify your source code in eclipse or netbeans, create war file then deploy, even better if you are using ant or maven you can deploy using those.

Upvotes: 2

Related Questions