Recently, when using Jenkins to deploy a project with one click, there was an exception invoking the Tomcat Manager, and the solution was especially noted.
Exception information
Possible exceptions: (1) Cannot invoke Tomcat manager: Error writing to server; (2) Cannot invoke Tomcat manager: Connection refused: connect -> [Help 1].
Abnormal
After checking the information, when installing Tomcat, the manager project is taken by default, which is responsible for the deployment of the WAR package and other functions. Since the use of manager requires account and password authentication, if the account and password are not configured, such an exception will be reported.
But there is still this situation. The configuration below is configured, but this exception will be reported. At this time, you need to restart Tomcat and then deploy. (The reason is the result of Tomcat’s remote address interceptor, you need to add the RemoteAddrValve attribute in /conf/Catalina/localhost/manager.xml, reference 3)
solution
1. The tomcat-maven-plugin plug-in added to the pom file of the web project. This plug-in is used to deploy the war package built by maven to the specified remote Tomcat container and configure the account and password information. The account password needs to be the same as the corresponding Tomcat The configuration of conf/tomcat-user.xml is the same.
1 < plugin > 2 < groupId > org.codehaus.mojo </ groupId > 3 < artifactId > tomcat-maven-plugin </ artifactId > 4 < version > 1.1 </ version > 5 < configuration > 6 < url >http:/ /ip/manager/text </ url > 7 < username > tomcat </ username > 8 <password> tomcat </ password > 9 < update > true </ update > 10 < path > /xxxx </ path > 11 </ configuration > 12 </ plugin >
Among them, url specifies the remote Tomcat, and path corresponds to the specific path in webapps.
2. Add the following role information in conf/tomcat-user.xml, and users with these roles
1 < role rolename ="manager-gui" /> 2 < role rolename ="manager-script" /> 3 < role rolename ="admin-gui" /> 4 < role rolename ="admin-script" /> 5 < user username ="tomcat" password ="tomcat" roles ="manager-gui,manager-script,admin-gui,admin-script" />
3. Some people say that it is necessary to modify the configuration file (USER_HOME/.m2/settings.xml) under the Maven user warehouse path. I did not change it, and it succeeded (also written here for reference). This configuration is the username and password that need to be configured when the local maven warehouse accesses the remote warehouse.
1 < settings > 2 ... 3 < servers > 4 ... 5 < server > 6 < id > my-tomcat </ id > 7 < username > manager </ username > 8 < password > managerPwd </ password > 9 </ server > 10 </ servers > 11 12 </ settings>
Similar Posts:
- [Solved] Jenkins deployed the war package to tomcat7 and reported an error
- Git Push Github ERROR: Permission to xxx.git denied to user
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1
- How does IntelliJ idea use Maven Tomcat plug to run web projects
- The .m2 file does not appear in the installation of maven [How to Solve]
- Git push submit error 403, processing method
- Maven: How to uses tomcat8 Maven plugin
- [Solved] Jenkins++:Jenkins Deploy war Pack to tomcat8 Error
- Git pull code authentication failed with error: fatal: authentication failed for “XXXX”
- How to Solve Gitlab Error: remote: The project you were looking for could not be found.