java.net.socketexception 连接重置由对等套接字写入错误通过 Jenkins 在 Tomcat7 上部署战争时(使用 Maven)
Posted
技术标签:
【中文标题】java.net.socketexception 连接重置由对等套接字写入错误通过 Jenkins 在 Tomcat7 上部署战争时(使用 Maven)【英文标题】:java.net.socketexception connection reset by peer socket write error While deploying war on Tomcat7 through Jenkins (Using Maven) 【发布时间】:2015-06-20 23:27:31 【问题描述】:我正在尝试通过 Jenkins 在 tomcat7 上部署一个基于 maven 的 Web 项目。当我尝试从命令提示符执行 maven 目标“mvn tomcat7:deploy”时,一切正常,并将应用程序部署在正在运行的 tomcat7 实例上。 现在我在 Jenkins 上为相同的项目设置了一个作业并收到套接字错误。下面是我的代码和来自 Jenkins 控制台的堆栈跟踪。
POM.xml 中的条目
<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>Tomcat7Server</server>
<path>/ElecnorMPR</path>
</configuration>
</plugin>
Apache Maven Settings.xml
<server>
<id>Tomcat7Server</id>
<username>tomcat</username>
<password>tomcat</password>
</server>
已经在tomcat-user.xml中定义了用户。
[DEBUG] Connection 0.0.0.0:51036<->127.0.0.1:8080 closed
[DEBUG] Closing the connection.
[DEBUG] Connection 0.0.0.0:51036<->127.0.0.1:8080 closed
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[DEBUG] Connection reset by peer: socket write error
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.conn.LoggingSessionOutputBuffer.write(LoggingSessionOutputBuffer.java:73)
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)
at org.apache.tomcat.maven.plugin.tomcat7.AbstractWarCatalinaMojo.execute(AbstractWarCatalinaMojo.java:68)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
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:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:318)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
at org.jvnet.hudson.maven3.launcher.Maven31Launcher.main(Maven31Launcher.java:132)
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.launchStandard(Launcher.java:331)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
at jenkins.maven3.agent.Maven31Main.launch(Maven31Main.java:181)
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 hudson.maven.Maven3Builder.call(Maven3Builder.java:136)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:71)
at hudson.remoting.UserRequest.perform(UserRequest.java:121)
at hudson.remoting.UserRequest.perform(UserRequest.java:49)
at hudson.remoting.Request$2.run(Request.java:325)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
[INFO] Retrying request
[DEBUG] Reopening the direct connection.
[DEBUG] Connecting to localhost:8080
[DEBUG] Attempt 2 to execute request
[DEBUG] Sending request: PUT /manager/text/deploy?path=%2FElecnorMPR HTTP/1.1
[DEBUG] >> "PUT /manager/text/deploy?path=%2FElecnorMPR HTTP/1.1[\r][\n]"
[DEBUG] >> "User-Agent: Apache Tomcat Maven Plugin/2.2[\r][\n]"
[DEBUG] >> "Content-Length: 33093536[\r][\n]"
[DEBUG] >> "Host: localhost:8080[\r][\n]"
[DEBUG] >> "Connection: Keep-Alive[\r][\n]"
[DEBUG] >> "Authorization: Basic dG9tY2F0OnRvbWNhdA==[\r][\n]"
[DEBUG] >> "[\r][\n]"
[DEBUG] >> PUT /manager/text/deploy?path=%2FElecnorMPR HTTP/1.1
[DEBUG] >> User-Agent: Apache Tomcat Maven Plugin/2.2
[DEBUG] >> Content-Length: 33093536
[DEBUG] >> Host: localhost:8080
[DEBUG] >> Connection: Keep-Alive
[DEBUG] >> Authorization: Basic dG9tY2F0OnRvbWNhdA==
Uploading: http://localhost:8080/manager/text/deploy?path=%2FElecnorMPR
【问题讨论】:
谁能尽快回答这个问题.. 你有解决这个问题的办法吗? 【参考方案1】:我在 heroku 中部署战争时也遇到了这个错误。但是重新部署后就成功部署了
【讨论】:
【参考方案2】:根据正在使用的 Maven 存储库,version policy 或 existing artifact 可能导致存储库关闭连接。无论是否有正确的错误消息,都可能发生这种情况。
我的问题是由前者使用 Gradle 和 Nexus 引起的。它只是在不同的项目中发出了正确的错误。
【讨论】:
以上是关于java.net.socketexception 连接重置由对等套接字写入错误通过 Jenkins 在 Tomcat7 上部署战争时(使用 Maven)的主要内容,如果未能解决你的问题,请参考以下文章
是啥导致我的 java.net.SocketException:连接重置? [复制]
如何修复 java.net.SocketException:损坏的管道?
Java 1.6 HttpsURLConnection:java.net.SocketException:连接重置
java.net.SocketException:recvfrom 失败:ETIMEDOUT(连接超时)