Fix Redeployment of Webapps to Tomcat in Windows
I came across an annoying bug today where I was able to deploy a webapp to Tomcat once, but subsequent redeployments resulted in an exception when attempting to write to the server.
It transpired the problem was being caused by Windows aggressively locking resources such that they were unable to be undeployed cleanly.
To fix this, navigate to $CATALINA_HOME/conf/context.xml and find the following text
<Context>
Edit it to include the following attribute, as below:
<Context antiJARLocking="true">
This fixed the issue for me, but further redeployment problems might be being caused by similarly aggressive locking. In these cases the antiResourceLocking=”true” attribute may be helpful, but this produces undesirable side-effects in production and creates issues when using non-standard work directories so should be used carefully.
I’ve also found it beneficial to clean out theĀ $CATALINA_HOME/temp/ directory on a fairly regular basis to avoid issues where Tomcat is unable to delete stale temporary files.
Hope this helps!
Leave a Reply
You must be logged in to post a comment.










