您的位置:首页 > 其它

Tomca7热部署问题:Connection reset by peer: socket write error

2017-09-23 14:59 501 查看

问题描述:

最近学习热部署问题时,遇到如下问题,搞了大半天。后来因为拼写错误。不过还是有必要提醒此处有个坑。报错:

[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error

错误代码如下:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ProjectName-rest 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> tomcat7-maven-plugin:2.2:redeploy (default-cli) > package @ ProjectName-rest >>>
[INFO]
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ ProjectName-rest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 9 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ ProjectName-rest ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ ProjectName-rest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ ProjectName-rest ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ ProjectName-rest ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ ProjectName-rest ---
[INFO] Packaging webapp
[INFO] Assembling webapp [ProjectName-rest] in [D:\Temp\template\ProjectName-rest\target\ProjectName-rest]
[INFO] Processing war project
[INFO] Copying webapp resources [D:\Temp\template\ProjectName-rest\src\main\webapp]
[INFO] Webapp assembled in [219 msecs]
[INFO] Building war: D:\Temp\template\ProjectName-rest\target\ProjectName-rest.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO]
[INFO] <<< tomcat7-maven-plugin:2.2:redeploy (default-cli) < package @ ProjectName-rest <<<
[INFO]
[INFO] --- tomcat7-maven-plugin:2.2:redeploy (default-cli) @ ProjectName-rest ---
[INFO] Deploying war to http://192.168.15.133:8080/ Uploading: http://192.168.15.133:8080/manager/test//deploy?path=%2F&update=true 
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request
Uploading: http://192.168.15.133:8080/manager/test//deploy?path=%2F&update=true 
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request
Uploading: http://192.168.15.133:8080/manager/test//deploy?path=%2F&update=true 
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request
Uploading: http://192.168.15.133:8080/manager/test//deploy?path=%2F&update=true 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.245 s
[INFO] Finished at: 2017-09-23T14:11:13+08:00
[INFO] Final Memory: 13M/32M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:redeploy (default-cli) on project ProjectName-rest: 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[/code] 

Tomcat7插件URL中应该加上/text/

如下所示:

部署命令:tomcat7:deploy for rdeploying:tomcat7:redeploy

配置Tomcat7插件 在 pom.xml

<plugin>
<!-- tomcat deploy plugin -->
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>TomcatServer</server>
<username>XXXX</username>
<password>XXXX</password>
<path>/XXXX</path>
</configuration>
</plugin>


tomcat-user.xml 配置

<role rolename="tomcat" />
<role rolename="manager-gui" />
<role rolename="manager-script" />
<user username="tomcat" password="tomcatuser"
roles="tomcat,manager-gui,manager-script" />


注意:我也测试了与Tomcat 8相同的设置。所以这个设置可以适用于这两个版本。

已知的限制

tomcat7 mojo还没有一些目标。这些容器目标可以与tomcat6 mojo一起使用,您只需要更新您的pom中的管理器URL。

使用http: //localhost:8080/manager/text而不是默认的tomcat6 url。

相关资料:

StackOverflow

Apache Tomcat Maven Plugin
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐