Patz
Patz

Reputation: 334

Tomcat deploy using tomcat7-maven-plugin fails with error "Cannot invoke Tomcat manager: Connection reset by peer: socket write error"

I am trying to set auto-deploy for my war to Tomcat using the Tomcat7-Maven-Plugin. However, its failing to deploy the file. From the console messages, it looks like it starts deploying but gets interrupted in between after ard 2 MB of transfer. Same happens for all retries and finally it fails.

$ mvn tomcat7:redeploy
    .
    .
    .  
[INFO] Deploying war to http://localhost:8080/policy-service
Uploading: http://localhost:8080/manager/text/deploy?path=%2Fpolicy-service&update=true
2244/52241 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=%2Fpolicy-service&update=true
2242/52241 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=%2Fpolicy-service&update=true
2242/52241 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=%2Fpolicy-service&update=true
2242/52241 KB
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

I tried all possible solutions which I could gather, but no luck:

  1. Changing POM config url from /manager/text to /manager/html.
  2. Not allocating manager-script or manager-jmx role to the same user having manager-gui role in tomcat-users.xml.
  3. Setting connector timeout from 20 sec to 60 sec in server.xml
  4. Changed max-file-size from default 50 MB to 80 MB. (As my war file size is 55 MBs.)

Some additional details as follows:

Upvotes: 3

Views: 7261

Answers (4)

Dicluu
Dicluu

Reputation: 1

The same exception appears when you didn't make install (mvn install tomcat7:deploy) and trying to deploy WAR (mvn tomcat7:deploy)

By the way, your IDE can use own maven so be careful when you configurating settings.xml

Another one case this exception appears it's when your WAR file already deployed on tomcat, so you need to redeploy (mvn tomcat7:redeploy)

Upvotes: 0

Ben Brand
Ben Brand

Reputation: 1

Relatively late to this one. I came across this issue when porting from Ubuntu to Windows 11.

Adding the username/password for Tomcat to the POM resolved the problem (and, of course, having the tomcat-users.xml set up for that user).

Strangely enough, on Linux, it all worked without that combo. O well.

Upvotes: 0

Patz
Patz

Reputation: 334

I resolved the issue. Problem was that the admin user I was using had access for the manager-gui and manager-status. For the deployment, it needs manager-script role access. I created new user having this role and used that one in my pom.xml and it worked.

Following is the entry I added in tomcat-users.xml:

<user username="script" password="xxxx" roles="manager-script,manager-jmx"/>

Upvotes: 6

guest
guest

Reputation: 11

I had faced the same issue.

Turned out maven tomcat plugin tried to upload as admin even though I specified another username. I then set tomcat user to admin with blank password and it worked.

Lame workaround but at least now you know where to look into.

Upvotes: 1

Related Questions