Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Talking about the Hot deployment of Tomcat7

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The so-called hot deployment is to put the new war package on the tomcat without downtime to achieve the goal of uninterrupted service and unnoticed by the user. The principle of implementation is very simple. Make a record here for later review.

1.1 install tomcat7

Reference address: https://www.jb51.net/article/101216.htm

1.2 configure user permissions in tomcat

We need to implement hot deployment, so we naturally need to operate tomcat through maven, so we need maven to obtain permission to operate tomcat. Now this step is to configure the operable permission of tomcat.

Under the tomcat installation directory, modify the conf / tomcat-user.xml file and add the following configuration under the node:

Manager-gui allows access to the html interface (that is, the URL path is / manager/html/*), that is, manual login to the management interface for hot deployment.

Manager-script allows access to the plain text interface (that is, the URL path is / manager/text/*), that is, automatic deployment using maven's plug-ins.

1.3 modify the pom file

Modify the pom.xml file of the project and add the following configuration under the node: configuration of tomcat7

Org.apache.tomcat.maven tomcat7-maven-plugin 8081 / http:// deployment server ip address: Port number / manager/text tomcat tomcat

Note: the red part is configured for automatic deployment.

1.4 set deployment commands

Generally, you can right-click the project to be deployed in eclipse, Run as-> Run configurations-> maven build-> right-click new, so that you can configure a new maven command to specify the command method:

The "tomcat7:deploy" command can be used for initial deployment

If you have already deployed using the "tomcat7:redeploy" command

Deployment skips testing: tomcat7:redeploy-DskipTests

1.5 attach relevant error resolution

1.Connection refused error

The error message is as follows:

[ERROR] Failed to execute goal org.apache.tomcat.maven: tomcat7-maven-plugin: 2.0-SNAPSHOT: deploy (default-cli) on project helloworld: Cannot invoke Tomcat manager: Connection refused: connect-> [Help 1]

Reason: Tomcat server was not started

Solution: start the Tomcat server before selecting Run

2. 401 error

The error message is as follows:

[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin: 2.0-SNAPSHOT:deploy (default-cli) on project helloworld: Cannot invoke Tomcat manager: Server returned HTTP response code: 401for URL: http://localhost:8080/manager/text/deploy?path=%2Fhelloworld-> [Help 1]

Reason: permission issu

The solution is $CATALINA_BASE/conf/tomcat-users.xml

For example, add permissions to the file D:\ apache-tomcat-7.0.34\ conf\ tomcat-users.xml

Modify the pom.xml file to add admin admin in

3.403 error

The error message is as follows:

[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin: 2.0-SNAPSHOT:deploy (default-cli) on project helloworld: Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/html/deploy?path=%2Fhelloworld-> [Help 1]

Cause: the problem may occur for two reasons, see solution for details

Solution:

1) if you are using Tomcat 7, you need to modify the url address deployed in pom.xml and change the http://localhost:8080/manager to http://localhost:8080/manager/text.

2) when assigning tomcat user rights, you need to have both manager-gui and manager-script permissions. When I encountered this problem, I forgot to assign manager-script permissions.

The correct conf/tomcat-users.xml configuration should be:

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report