Tomcat7 maven 插件 - I/O 异常(java.net.SocketException)在处理请求时捕获:管道损坏

Tomcat7 maven plugin - I/O exception (java.net.SocketException) caught when processing request: Broken pipe

我一直在尝试使用 mvn tomcat7:deploy 命令来部署我的 WAR 文件,但我正在使用 Ubuntu 时管道损坏 errors.I。这是所需的文件。

这是POM.xml

  <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.0</version>
            <configuration>
                    <url>http://localhost:8080/manager/text</url>
                    <server>TomcatServer</server>
                    <path>/helloworld</path>
            </configuration>
        </plugin>
    </plugins>

我的 /conf/settings.xml tomcat 有

<server>
    <id>TomcatServer</id>
    <username>maven</username>
    <password>maven</password>

和tomcatusers.xml如下

  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="admin"/>
  <user username="maven" password="maven" roles="admin,managerscript,manager-gui"/>

使用以下命令部署时

mvn tomcat7:deploy

我收到这些错误

> Uploading: http://localhost:8080/manager/text/deploy?path=%2Fhelloworld
120/23235 KB
Feb 28, 2018 1:11:42 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing request: Connection reset
Feb 28, 2018 1:11:42 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Fhelloworld
2/23235 KB
Feb 28, 2018 1:11:42 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing request: Broken pipe (Write failed)
Feb 28, 2018 1:11:42 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Fhelloworld
2/23235 KB
Feb 28, 2018 1:11:42 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing request: Broken pipe (Write failed)
Feb 28, 2018 1:11:42 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Fhelloworld
2/23235 KB
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.061 s
[INFO] Finished at: 2018-02-28T13:11:42+05:00
[INFO] Final Memory: 15M/60M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.0:deploy (default-cli) on project springmvc-helloworld: Cannot invoke Tomcat manager: Broken pipe (Write failed) -> [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

我已经找了一段时间了,没能解决这个问题。

在您的 tomcatusers.xml 中,对于您具有角色 "managerscript" 的用户 maven,将其更改为管理脚本。 此外,如果您是 运行 maven 来自与 tomcat 不同的机器,请使用机器的 ip 地址并确保端口 8080 已打开以进行通信。