Maven的Tomcat部署产生错误

Maven的Tomcat部署产生错误

本文介绍了Maven的Tomcat部署产生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用tomcat7:deploy目标将Java Web应用程序部署到我的tomcat服务器中.但是我遇到以下错误

I wanted to deploy my java webapp into my tomcat server using tomcat7:deploy goal. But i am getting following error

enter code[INFO] Deploying war to http://localhost:8080/CounterWebApp
Uploading: http://localhost:8080/manager/text/deploy?path=%2FCounterWebApp
2500/5423 KB
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2FCounterWebApp
2436/5423 KB
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2FCounterWebApp
2500/5423 KB
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2FCounterWebApp
2436/5423 KB
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.588 s
[INFO] Finished at: 2016-12-21T10:42:39+05:30
[INFO] Final Memory: 18M/158M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project CounterWebApp: Cannot invoke Tomcat manager: Connection reset by peer: socket write error -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException here

我在浏览器上手动尝试的以下行出现了错误

the following line i tried on my browser manually and was producing error

http://localhost:8080/manager/text/deploy?path=%2FCounterWebApp

但是当我与下面的war文件一起指定时,它可以在浏览器中成功运行.

but when i specify along with war file as below it successfully works in browser.

http://localhost:8080/manager/text/deploy?path=%2FCounterWebApp&war=file:F:\documents\repositories\webcounter\target\CounterWebApp.war

那就像是tomcat7-maven-plugin弄错了吗?如果这是我将如何解决它,或者我在某个地方犯了一个错误?

so is it be like tomcat7-maven-plugin making a mistake? if it is how will i fix it or is there a mistake i made somewhere?

下面是我在pom文件中提供的插件标签

below is the plugin tag i gave in pom file

<plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <path>/${project.build.finalName}</path>
                </configuration>
            </plugin>

下面是我为tomcat-users.xml创建的xml文件用户

below is the xml file users i created for tomcat-users.xml

role rolename="manager-gui"/>
      <role rolename="manager-script"/>
      <role rolename="manager-jmx"/>
      <role rolename="manager-status"/>
      <role rolename="admin-gui"/>
      <role rolename="admin-script"/>
      <user username="test" password="test" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>

下面是我包含在maven settings.xml中的那个

below is the one i included in maven settings.xml

<server>
<id>mytomcat</id>
<username>test</username>
<password>test</password>
</server>

推荐答案

在$ {TOMCAT_HOME}/conf/Catalina/localhost/manager.xml

in ${TOMCAT_HOME}/conf/Catalina/localhost/manager.xml

从Valve周围删除注释标记

Remove the comment markers from around the Valve

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

然后访问 http://127.0.0.1/manager/html ,您将看到管理器页面

then access http://127.0.0.1/manager/html, you will look manager page

这篇关于Maven的Tomcat部署产生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 18:26