Deploying artifacts to Tomcat will sometimes fail on due to file locking

Still need help?

The Atlassian Community is here for you.

Ask the community

When a plan is configured to use Deploy Tomcat application task to deploy the generated artifacts to Tomcat (as explained here - Using Tomcat with Bamboo for continuous deployment) and if it sometimes fails with the below error in the build logs:

Starting task 'Deploy test' of type 'com.atlassian.bamboo.plugins.tomcat.bamboo-tomcat-plugin:deployAppTask'
Deploying application with war file 'test.war' to context '/hello' to server 'http://localhost:8080/manager/'
Application failed to deploy: FAIL - Unable to delete [D:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\hello]. The continued presence of this file may cause problems.
FAIL - Application already exists at path /hello

Cause

This is more common in Windows OS where Tomcat will lock files or directory location. In most cases this happens after the first succesfull deployment and subsequent ones will be blocked. Even though this is more common in Windows, it might affect the linux OS as well and the same resolution should be applied on both.

Resolution

This can be fixed by  adding <Context antiResourceLocking="true"> to Tomcat context. The  antiResourceLocking is by default set to false. More details can be read at http://tomcat.apache.org/tomcat-5.5-doc/config/context.html .

Last modified on Mar 15, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.