1.Jenkins部署TomcatManagerExcepion问题
1.1异常提示:
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)
解决方法是到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" />
--> //注释掉即可
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>
1.2异常提示
org.codehaus.cargo.container.ContainerException: Failed to undeploy [C:\Users\F3234199\.jenkins\workspace\******web.war]
**************************
省略中间异常信息
************************
Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The Tomcat Manager responded "FAIL - Unable to delete [D:\Project\apache-tomcat-8.5.24\webapps\**-web]. The continued presence of this file may cause problems.
" instead of the expected "OK" message
解决办法:
1. 打开tomcat安装目录下的/conf/context.xml
2.修改<Context>元素中增加一个属性antiResourceLocking="true" antiJARLocking="true",默认是"false"
<Context antiResourceLocking="true" antiJARLocking="true">
<!-- Default set of monitored resources. If one of these changes, the -->
<!-- web application will be reloaded. -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
</Context>
2.Jenkins部署SocketException异常提示
ERROR: Build step failed with exception
org.codehaus.cargo.container.ContainerException: Failed to redeploy
-----------------省略其他提示信息---------------
Caused by: java.net.SocketException: Software caused connection abort: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
-----------------省略其他提示信息---------------
java.net.SocketException: Software caused connection abort: recv failed
可能出现的问题点,构建后操作的 Context Path 配置有问题,配置的是发布tomcat后的访问地址路径