Undeploying tomcat web app fails due to locked files

The continuous build for my current project was failing occasionally due to problems undeploying a web application from Tomcat 5.5. Tomcat was holding locks on a jar file within WEB-INF/lib, preventing the web app from being undeployed or deleted

It seems there is a workaround for this, at least for test systems (I don’t think this technique is recommended for production use)
Within the context.xml in the tomcat conf dir, you can add antiJARLocking=”true” antiResourceLocking=”true”

This will cause tomcat to deploy webapps into a .\temp directory and in theory take no locks on the files.
It seems over time the contents of the temp dir can build up, so it may be necessary to do some pruning occasionally.

However, for continuous build servers this may at least solve the immeditate problem with undeploying apps.

<!-- The contents of this file will be loaded for each web application -->
<Context antiJARLocking="true" antiResourceLocking="true" >

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
   
    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->

</Context>




You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply