(java.net.SocketException) 在处理请求时被捕获:连接被对等重置:套接字写入错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34427901/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
(java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
提问by Gnostikoi
I had a I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
problem When using maven plugin to deploy tomcat
This problem has haunted me for days. I couldn't use tomcat7:deploy to upload my war file via maven plugin, due to connection reset by peers
error.
Here's part of my pom.xml
我I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
在使用maven插件部署tomcat时遇到了一个 问题 这个问题困扰了我好几天。由于connection reset by peers
错误,我无法使用 tomcat7:deploy 通过 maven 插件上传我的War文件。这是我的 pom.xml 的一部分
<build>
<finalName>Project</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<server>tomcat</server>
<url>http://myserver/manager/text</url>
<username>admin</username>
<password>admin</password>
<path>/plainart</path>
</configuration>
</plugin>
</plugins>
</pluginManagement>
and here's the console log
这是控制台日志
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for cn.edu.xmu.plainart:cn.edu.xmu.plainart:war:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: cglib:cglib:jar -> version ${cglib.version} vs 2.2.2 @ line 89, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building cn.edu.xmu.plainart 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> tomcat7-maven-plugin:2.2:deploy (default-cli) > package @ cn.edu.xmu.plainart >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ cn.edu.xmu.plainart ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ cn.edu.xmu.plainart ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ cn.edu.xmu.plainart ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ cn.edu.xmu.plainart ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ cn.edu.xmu.plainart ---
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ cn.edu.xmu.plainart ---
[INFO] Packaging webapp
[INFO] Assembling webapp [cn.edu.xmu.plainart] in [C:\Users\Luna\Documents\GitHub\PiedPiper\Project\target\Project]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\Users\Luna\Documents\GitHub\PiedPiper\Project\src\main\webapp]
[INFO] Webapp assembled in [3376 msecs]
[INFO] Building war: C:\Users\Luna\Documents\GitHub\PiedPiper\Project\target\Project.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO]
[INFO] <<< tomcat7-maven-plugin:2.2:deploy (default-cli) < package @ cn.edu.xmu.plainart <<<
[INFO]
[INFO] --- tomcat7-maven-plugin:2.2:deploy (default-cli) @ cn.edu.xmu.plainart ---
[INFO] Deploying war to http://104.236.166.121:8080/plainart
Uploading: http://104.236.166.121:8080/manager/text/deploy?path=%2Fplainart
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request
Uploading: http://104.236.166.121:8080/manager/text/deploy?path=%2Fplainart
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request
Uploading: http://104.236.166.121:8080/manager/text/deploy?path=%2Fplainart
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request
Uploading: http://104.236.166.121:8080/manager/text/deploy?path=%2Fplainart
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 40.818 s
[INFO] Finished at: 2015-12-23T10:51:22+08:00
[INFO] Final Memory: 19M/160M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project cn.edu.xmu.plainart: Cannot invoke Tomcat manager: Connection reset by peer: socket write error -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project cn.edu.xmu.plainart: Cannot invoke Tomcat manager
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot invoke Tomcat manager
at org.apache.tomcat.maven.plugin.tomcat7.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:141)
at org.apache.tomcat.maven.plugin.tomcat7.AbstractWarCatalinaMojo.execute(AbstractWarCatalinaMojo.java:68)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused by: java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
at java.net.SocketOutputStream.write(SocketOutputStream.java:159)
at org.apache.http.impl.io.AbstractSessionOutputBuffer.write(AbstractSessionOutputBuffer.java:181)
at org.apache.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:115)
at org.apache.tomcat.maven.common.deployer.TomcatManager$RequestEntityImplementation.writeTo(TomcatManager.java:880)
at org.apache.http.entity.HttpEntityWrapper.writeTo(HttpEntityWrapper.java:89)
at org.apache.http.impl.client.EntityEnclosingRequestWrapper$EntityWrapper.writeTo(EntityEnclosingRequestWrapper.java:108)
at org.apache.http.impl.entity.EntitySerializer.serialize(EntitySerializer.java:117)
at org.apache.http.impl.AbstractHttpClientConnection.sendRequestEntity(AbstractHttpClientConnection.java:265)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.sendRequestEntity(ManagedClientConnectionImpl.java:203)
at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:236)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:121)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:682)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:486)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.tomcat.maven.common.deployer.TomcatManager.invoke(TomcatManager.java:742)
at org.apache.tomcat.maven.common.deployer.TomcatManager.deployImpl(TomcatManager.java:705)
at org.apache.tomcat.maven.common.deployer.TomcatManager.deploy(TomcatManager.java:388)
at org.apache.tomcat.maven.plugin.tomcat7.deploy.AbstractDeployWarMojo.deployWar(AbstractDeployWarMojo.java:85)
at org.apache.tomcat.maven.plugin.tomcat7.deploy.AbstractDeployMojo.invokeManager(AbstractDeployMojo.java:82)
at org.apache.tomcat.maven.plugin.tomcat7.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:132)
... 23 more
[ERROR]
[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
and the remote tomcat-user.xml is configured.
并配置了远程tomcat-user.xml。
I don't know how to fix this problem. If there's any infomation useful to troubleshooting that I could offer, please let me know.
我不知道如何解决这个问题。如果我可以提供任何对故障排除有用的信息,请告诉我。
Thanks in advance
提前致谢
回答by Sabir Khan
Try these ,
试试这些,
use redeployinstead of deploy
Default war size in tomcat is 50 MB, try to increase that if your war is bigger than 50 MB
Lots of users listed cause to me missing roles in tomcat-users.xml. Try adding manager-script role if missing , Question Link
Tomcat7 plugin might be picking server details from the maven conf settings.xml instead of .m2\settings.xml .Adding server information in that file might resolve issue.
使用重新部署而不是部署
tomcat 中的默认War大小为 50 MB,如果您的War大于 50 MB,请尝试增加该大小
列出的许多用户导致我缺少 tomcat-users.xml 中的角色。如果缺少,请尝试添加 manager-script 角色,问题链接
Tomcat7 插件可能会从 maven conf settings.xml 而不是 .m2\settings.xml 中选择服务器详细信息。在该文件中添加服务器信息可能会解决问题。
回答by Amine Aouffen
In addition to @Sabir Khan's answer. You need to check if the value of server in the plugin configuration is the same as the server id in the settings.xml
除了@Sabir Khan 的回答。需要检查插件配置中server的值是否与settings.xml中的server id一致
So in the pom.xml
you are having :
所以在pom.xml
你有:
<plugin>
...
<configuration>
...
<server>MyTomcatServer</server>
...
</configuration>
...
</plugin>
be sure in the settings.xml
of maven you have :
确保在settings.xml
Maven 中你有:
<servers>
...
<server>
<id>MyTomcatServer</id>
<username>username_here</username>
<password>password_here</password>
</server>
...
</servers>
Otherwise, tomcat will try to use admin account (if it is not configured, the server will refuse the auth)
否则tomcat会尝试使用admin账号(如果没有配置,服务器会拒绝auth)