【问题标题】:maven tomcat deployment producing errormaven tomcat部署产生错误
【发布时间】:2017-05-06 11:02:34
【问题描述】:

我想使用 tomcat7:deploy 目标将我的 java webapp 部署到我的 tomcat 服务器中。但我收到以下错误

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

我在浏览器上手动尝试了以下行并产生错误

FAIL - 为命令 [/deploy] 提供的参数无效

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

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

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

是不是就像 tomcat7-maven-plugin 出错了?如果是我将如何解决它或者我在某个地方犯了错误?

下面是我在 pom 文件中给出的插件标签

<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文件users

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 中的那个

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

【问题讨论】:

    标签: java maven deployment tomcat7


    【解决方案1】:

    如this answer 中指出的那样,在该上下文下已经存在部署可能是一个问题。

    【讨论】:

      【解决方案2】:

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

      移除 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,你会看到管理页面

      【讨论】:

      • 这并不能解决无法从Maven部署的问题。它只会将您锁定为只能从 localhost 进行部署。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-28
      • 2014-09-06
      • 2017-04-17
      • 2015-02-05
      • 2011-12-06
      相关资源
      最近更新 更多