ERROR: Build step failed with exceptionorg.codehaus.cargo.container.ContainerException: Failed to re
ERROR: Build step failed with exceptionorg.codehaus.cargo.container.ContainerException: Failed to redeploy [C:/Users/bt/.jenkins/workspace/surfond-scbs/target/surfond-scbs-server-1.0.0.war] at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:189) 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:996) at hudson.FilePath.act(FilePath.java:974) 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:779) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720) at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1067) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665) at hudson.model.Run.execute(Run.java:1753) at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:544) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:405)Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The username you provided is not allowed to use the text-based Tomcat Manager (error 403) at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:555) at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:686) at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:699) at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:174) ... 16 moreCaused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://192.168.1.188:9080//manager/text/list at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474) at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:544) ... 19 moreorg.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The username you provided is not allowed to use the text-based Tomcat Manager (error 403) at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:555) at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:686) at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:699) at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:174) 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:996) at hudson.FilePath.act(FilePath.java:974) 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:779) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720) at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1067) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665) at hudson.model.Run.execute(Run.java:1753) at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:544) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:405)Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://192.168.1.188:9080//manager/text/list at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474) at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:544) ... 19 moreBuild step 'Deploy war/ear to a container' marked build as failureFinished: FAILURE
直接访问Tomcat页面的时候:
You are not authorized to view this page.
By default the Manager is only accessible from a browser running on the same machine as Tomcat. If you wish to modify this restriction, you'll need to edit the Manager's context.xml file.
If you have already configured the Manager application to allow access and you have used your browsers back button, used a saved book-mark or similar then you may have triggered the cross-site request forgery (CSRF) protection that has been enabled for the HTML interface of the Manager application. You will need to reset this protection by returning to the main Manager page. Once you return to this page, you will be able to continue using the Manager appliction's HTML interface normally. If you continue to see this access denied message, check that you have the necessary permissions to access this application.
If you have not changed any configuration files, please examine the file conf/tomcat-users.xml in your installation. That file must contain the credentials to let you use this webapp.
For example, to add the manager-gui role to a user named tomcat with a password of s3cret, add the following to the config file listed above.
<role rolename="manager-gui"/>
<user username="tomcat" password="s3cret" roles="manager-gui"/>
Note that for Tomcat 7 onwards, the roles required to use the manager application were changed from the single manager role to the following four roles. You will need to assign the role(s) required for the functionality you wish to access.
manager-gui - allows access to the HTML GUI and the status pages
manager-script - allows access to the text interface and the status pages
manager-jmx - allows access to the JMX proxy and the status pages
manager-status - allows access to the status pages only
The HTML interface is protected against CSRF but the text and JMX interfaces are not. To maintain the CSRF protection:
Users with the manager-gui role should not be granted either the manager-script or manager-jmx roles.
If the text or jmx interfaces are accessed through a browser (e.g. for testing since these interfaces are intended for tools not humans) then the browser must be closed afterwards to terminate the session.
For more information - please see the Manager App HOW-TO.
大概意思就是:
您没有权限查看此页。
默认情况下,管理器只能从运行在同一台机器上的浏览器。如果你想修改这一限制,您需要编辑经理的context.xml文件中。
如果您已经配置管理器应用程序允许你使用你的浏览器的后退按钮,用于保存的书签或类似你可能引发跨站请求伪造(CSRF)的保护,已经为管理应用HTML接口启用。您将需要重置此保护返回到主管理器页。一旦你返回到本页,你将能够继续使用管理应用的HTML界面正常。如果继续查看此访问拒绝消息,请检查您是否有访问该应用程序的必要权限。
如果你没有更改任何配置文件,请检查您的安装文件conf/tomcat-users.xml。该文件必须包含证书让你使用这个程序。
例如,添加经理桂作用一个用户名为tomcat的密码的s3cret,添加以下上面列出的配置文件。
<作用rolename =“经理桂”/>
<用户名和密码“Tomcat”=“=”s3cret”角色管理器GUI”/>
注意,对于Tomcat 7来说,使用管理器应用程序所需的角色从单个管理器角色更改为以下四个角色。您需要指定您希望访问的功能所需的角色。
管理器GUI -允许访问HTML GUI和状态页
管理器脚本-允许访问文本界面和状态页
经理JMX允许访问JMX代理和状态页面
管理器状态-只允许访问状态页
HTML界面免受CSRF但文字和JMX接口不。保持CSRF保护:
与经理的GUI用户角色不应该被授予或经理或经理JMX角色脚本。
如果文本或JMX接口是通过浏览器访问(例如测试这些接口的目的是为工具而不是人类)然后浏览器必须关闭之后终止会话。
欲了解更多信息-请参阅管理器应用程序。
解决方案:
tomcat/conf/tomcat-users.xml加入:
<role rolename="manager"/>
<role rolename="admin"/>
<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<user username="xxx" password="***" roles="admin-gui,manager-gui"/>
以上是Tomcat 7 的修改就行了。
Tomcat 9 的话
需要修改Tomcat/webapps/manager/META-INF/context.xml文件:
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127/./d+/./d+/./d+|::1|0:0:0:0:0:0:0:1|/d+/./d+/./d+/./d+" />
或者直接注释掉