1

I have a build configuration that uses the Team City deployer plugin. I'm using a container deploy to deploy the war file to Tomcat.7.0.63 installed as a service on a Windows Server 2012 R2 box. The first time I run the the build, the artifact (a war file_ deploys successfully. The second time, and all subsequent runs, the deploy fails.

The error message:

Build failure message received: org.codehaus.cargo.container.ContainerException: Failed to undeploy

The log file error:

Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: FAIL - Unable to delete

When I go to the webapps folder on the remote server, the war file is deleted, but the expanded folder is only partially deleted. Most files are gone, except for a png file. I am not able to manually delete the folder because Tomcat still has a lock on it. If I restart tomcat, I'm then able to run the build successfully (war file deploys).

One thought I had was to restart Tomcat before or after each deploy. How would I restart Tomcat from TeamCity? Or perhaps, does anyone have suggestions on how to fix this problem?

Pytry
  • 6,044
  • 2
  • 37
  • 56
  • 1
    Looking at the [Tomcat7 config docs](http://tomcat.apache.org/tomcat-7.0-doc/config/context.html); have you tried the `antiResourceLocking` option? – SteveChapman Aug 28 '15 at 01:23
  • I have not. I'll look into that. – Pytry Aug 28 '15 at 14:46
  • @SteveChapman You're suggestion for using antiResourceLocking worked fantastically. I also added the "reloadable" option since this is an integration test server, with multiple redeploys possibly happening through the day. Create an answer with your suggestion and I will mark it as correct. – Pytry Aug 28 '15 at 20:29
  • Glad it worked; answer has been added. – SteveChapman Aug 31 '15 at 22:16
  • FYI: found out how to remotely start/stop a service on windows. TeamCity has a command line runner which could be used to execute a .bat file with sc \\ start\stop http://stackoverflow.com/questions/187836/how-do-i-restart-a-service-on-a-remote-machine-in-windows – Pytry Sep 01 '15 at 14:08

1 Answers1

1

You can configure the Tomcat Context using the antiResourceLocking option, as detailed further in the online documentation. This does come with some trade-offs however; definitely worth reading the documentation in full and evaluating if it's a suitable option for your application.

SteveChapman
  • 3,051
  • 1
  • 22
  • 37
  • What are your thoughts on using this in production? I found that if I just wait about five minutes (more than enough time for the application to finish loading in Tomcat), then I can run the TeamCity deploy again without using this parameter. So for production, it might not be needed, but since this is integration testing, and I might have impatient testers hitting that "Run" button, I decided to make it fault tolerant. – Pytry Sep 01 '15 at 13:57