Reputation: 36715
Usually, when I put an updated WAR file in Tomcat's webapps
folder, the appropriate webapp is automatically updated.
But sometimes, when I put in an updated WAR file, a strange thing happens: most of that webapp's folder is deleted, except some random collection of files. Of course in this case the webapp no longer works. To make it work, I must stop Tomcat, delete the folder of that webapp entirely, then restart Tomcat.
I tried to stop the webapp from the Tomcat manager before putting the WAR file in webapps
- it didn't help.
I tried to change autodeploy
and/or unpackwars
to false, but then the webapp was not updated at all when I put in the new warfile.
I also tried to use Jenkins' deployment plugin, but the same problem happened.
System spec: Tomcat 7 on Windows 2003.
Upvotes: 1
Views: 5082
Reputation: 3103
Disclaimer: 1. Yes, I know this is an old question. 2. Completely untested.
I have not tried this, so this is untested purely "by the books" stuff. Here goes.
The Tomcat7 documentation (archived here) at least mentions that you need extra steps for hot deploy on Windows. Namely...
on Windows, this assumes that anti-locking features (see Context configuration) are enabled, otherwise it is not possible to delete the resources of a running web application.
...and the appropriate configuration switch seems to be something called antiResourceLocking
, which apparently...
allows full webapp hot deploy and undeploy on platforms or configurations where file locking can occur
And I'm not sure, but all of this does indeed sound a bit like "undefined behavior can happen if you try to hot-deploy on Windows WITHOUT antiResourceLocking=true". And that sounds just terrible.
Upvotes: 0
Reputation: 36715
According to Tomcat 7 configuration guide: http://tomcat.apache.org/tomcat-7.0-doc/config/host.html#Automatic%20Application%20Deployment
"Updating a WAR file will trigger an undeploy of the application, with the removal of any associated expanded directory, context file and work directory. Any current user sessions will not be persisted... The application will be redeployed the next time the auto deployer checks for changes."
Probably, the problem is that the auto-deployer still hasn't finished to remove the expanded directory, while another thread started re-deploying it.
My workaround is to delete the old war-file, wait until the directory is removed, and only then put the new war-file, since:
"Deleting a WAR file will trigger an undeploy of the application, with the removal of any associated expanded directory, context file and work directory. Any current user sessions will not be persisted."
Upvotes: 3