构建步骤失败,发生异常org.codehaus.cargo.container.ContainerException:无法重新部署

时间:2018-11-15 07:32:27

标签: java tomcat jenkins devops

尝试使用Jenkins部署WAR时出现错误消息。

我创建了一个新的Deploy-to-staging项目,其配置如下:

在尝试构建(Project Build)代码时,部署到阶段失败,并且我得到

  

错误:构建步骤失败,出现异常   org.codehaus.cargo.container.ContainerException:无法重新部署[/var/lib/jenkins/workspace/Deploy-to-staging/webapp/target/webapp.war]       在org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:188)       在hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)       在hudson.plugins.deploy.CargoContainerAdapter $ DeployCallable.invoke(CargoContainerAdapter.java:147)       在hudson.plugins.deploy.CargoContainerAdapter $ DeployCallable.invoke(CargoContainerAdapter.java:117)       在hudson.FilePath.act(FilePath.java:1077)       在hudson.FilePath.act(FilePath.java:1060)       在hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)       在hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)       在hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)       在hudson.tasks.BuildStepMonitor $ 3.perform(BuildStepMonitor.java:45)       在hudson.model.AbstractBuild $ AbstractBuildExecution.perform(AbstractBuild.java:744)       在hudson.model.AbstractBuild $ AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)       在hudson.model.Build $ BuildExecution.post2(Build.java:186)       在hudson.model.AbstractBuild $ AbstractBuildExecution.post(AbstractBuild.java:635)       在hudson.model.Run.execute(Run.java:1844)       在hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)       在hudson.model.ResourceController.execute(ResourceController.java:97)       在hudson.model.Executor.run(Executor.java:429)   原因:org.codehaus.cargo.container.tomcat.internal.TomcatManagerException:您提供的用户名和密码不正确(错误401)       在org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:698)       在org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:876)       在org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:889)       在org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:173)       ...另外17个   由以下原因导致:java.io.IOException:服务器返回的HTTP响应代码:401用于URL:http://localhost:8090//manager/text/list       在sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)       在sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)       在org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:571)       ...另外20个   org.codehaus.cargo.container.tomcat.internal.TomcatManagerException:您提供的用户名和密码不正确(错误401)       在org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:698)       在org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:876)       在org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:889)       在org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:173)       在hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)       在hudson.plugins.deploy.CargoContainerAdapter $ DeployCallable.invoke(CargoContainerAdapter.java:147)       在hudson.plugins.deploy.CargoContainerAdapter $ DeployCallable.invoke(CargoContainerAdapter.java:117)       在hudson.FilePath.act(FilePath.java:1077)       在hudson.FilePath.act(FilePath.java:1060)       在hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)       在hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)       在hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)       在hudson.tasks.BuildStepMonitor $ 3.perform(BuildStepMonitor.java:45)       在hudson.model.AbstractBuild $ AbstractBuildExecution.perform(AbstractBuild.java:744)       在hudson.model.AbstractBuild $ AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)       在hudson.model.Build $ BuildExecution.post2(Build.java:186)       在hudson.model.AbstractBuild $ AbstractBuildExecution.post(AbstractBuild.java:635)       在hudson.model.Run.execute(Run.java:1844)       在hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)       在hudson.model.ResourceController.execute(ResourceController.java:97)       在hudson.model.Executor.run(Executor.java:429)   由以下原因导致:java.io.IOException:服务器返回的HTTP响应代码:401用于URL:http://localhost:8090//manager/text/list       在sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)       在sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)       在org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:571)       ...另外20个   构建步骤“将战争/耳朵部署到容器”将构建标记为失败   完成:失败

我该如何解决?

我的tomcat凭据位于[tomcat目录] /conf/tomcat-users.xml中,如下所示:

<tomcat-users>
    <role rolename="manager-script"/>
    <role rolename="admin-gui"/>
    <user username="tomcat" password="tomcat" roles="manager-script,admin-gui" />       

1 个答案:

答案 0 :(得分:0)

context.xml个文件中注释Valve标记

<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />

tomcat目录中有多个context.xml文件,更新以下context.xml文件并重新启动tomcat服务-

  • /apache-tomcat-8.5.41/webapps/manager/META-INF/context.xml
  • /apache-tomcat-8.5.41/webapps/host-manager/META-INF/context.xml