1
votes

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.

1
If you copy foo.war into webapps tomcat will redeploy your application. Check catalina.out for logs. You don't have to restart tomcat on every deploy.tshenolo
Are you saying Tomcat will automatically redeploy foo, but only if we don't first shutdown Tomcat? Interesting. In some of our apps, deployment is an exploded war because we have to modify files inside the war when we deploy. Maybe we should change our thinking and do all live deployments.David W.
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.tshenolo
Thanks for your insight. I'll have to talk to the developers about this. There may be an issue because we have multiple servers and databases involved. However, not shutting down and bringing back up the server would greatly simplify installs. The big problem is the xml file under $CATALINA_BASE/conf/Catalina/localhost. This is sometimes updated. Also, the war contains configuration files that differ from server to server. We have to explode the war and change those files. I've always thought the process was way more complicated than necessary.David W.
@tshenolo Provide an answer, so I can accept it.David W.

1 Answers

2
votes

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.