小编典典

使用Jenkins在远程Tomcat8上部署时,您提供的用户名不允许使用基于文本的Tomcat管理器(错误403)

tomcat

我正在尝试使用Jenkins部署到容器插件在远程Tomcat(远程计算机)上部署WAR。我在tomcat-users.xml中完成了以下配置

<user username="deployer" password="deployer" roles="manager-gui,manager-script,admin" />

我在Jenkins部署程序容器插件中设置了正确的用户名密码和端口。该设置对于本地Tomcat运行正常。但是对于远程Tomcat,我一直收到以下错误:

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 more Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://1.203.190.5:8080/manager/text/list at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown

Source) at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:544) ... 19 more

请帮忙。


阅读 916

收藏
2020-06-16

共1个答案

小编典典

这似乎是一个詹金斯(Jenkins)错误,但我通过在Tomcat中设置以下配置解决了这个问题:

编辑文件/webapps/manager/META-INF/context.xml:

以前:

<Context antiResourceLocking="false" privileged="true">

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

</Context>

更改此文件以注释值:

<Context antiResourceLocking="false" privileged="true">

  <!--

    <Valve className="org.apache.catalina.valves.RemoteAddrValve"

         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />

    -->

</Context>

这解决了问题。希望这可以帮助某人:)

2020-06-16