Tomcat Undeploy Failed Error

今天在windows下面部署了tomcat,并且利用jenkins来实现自动部署。
第一次部署时,war包安装顺利,也能正常访问。
第二次部署时,就报不能正常删除自己发布的旧的工程,导致失败。
org.codehaus.cargo.container.ContainerException: Failed to undeploy [C:\.jenkins\jobs\TestProject\workspace\test-web\target\test.war]
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.undeploy(AbstractTomcatManagerDeployer.java:140)
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:178)
	at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)
	at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:116)
	at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:103)
	at hudson.FilePath.act(FilePath.java:914)
	at hudson.FilePath.act(FilePath.java:887)
	at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)
	at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)
	at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:804)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:776)
	at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1030)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:725)
	at hudson.model.Run.execute(Run.java:1701)
	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:519)
	at hudson.model.ResourceController.execute(ResourceController.java:88)
	at hudson.model.Executor.run(Executor.java:231)
Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: FAIL - Unable to delete [C:\Apache Software Foundation\Tomcat 7.0\webapps\test]. The continued presence of this file may cause problems.

	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:566)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:480)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.undeploy(TomcatManager.java:420)
	at org.codehaus.cargo.container.tomcat.Tomcat7xRemoteDeployer.performUndeploy(Tomcat7xRemoteDeployer.java:62)
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.undeploy(AbstractTomcatManagerDeployer.java:130)
	... 17 more
org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: FAIL - Unable to delete [C:\Apache Software Foundation\Tomcat 7.0\webapps\test]. The continued presence of this file may cause problems.

	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:566)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:480)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.undeploy(TomcatManager.java:420)
	at org.codehaus.cargo.container.tomcat.Tomcat7xRemoteDeployer.performUndeploy(Tomcat7xRemoteDeployer.java:62)
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.undeploy(AbstractTomcatManagerDeployer.java:130)
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:178)
	at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)
	at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:116)
	at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:103)
	at hudson.FilePath.act(FilePath.java:914)
	at hudson.FilePath.act(FilePath.java:887)
	at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)
	at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)
	at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:804)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:776)
	at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1030)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:725)
	at hudson.model.Run.execute(Run.java:1701)
	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:519)
	at hudson.model.ResourceController.execute(ResourceController.java:88)
	at hudson.model.Executor.run(Executor.java:231)

错误信息很明显,就是不能删除我们的发布的工程test
我又去看了tomcat的user是否有权限,发现是有的,因为我把很多role都一起付给他了。
<user name="admin" password="admin" roles="admin-gui,manager,manager-script,manager-jmx,manager-gui,manager-status" />
后来发现有可能是antiResourceLocking属性引起的,参考如下:http://stackoverflow.com/questions/14873219/cannot-undeploy-a-web-app-completely-in-tomcat-7
修改context.xml文件 <Context antiResourceLocking="true">
再次重启tomcat, 多次利用jenkins重新自动部署都成功了。

你可能感兴趣的:(tomcat,windows,undeploy)