Tomcat 7: Connection reset by peer or Software caused connection abort
Asked Answered
A

6

14

I have a problem when I'm trying to deploy Java-application.

Cannot invoke Tomcat manager: Connection reset by peer: socket write error

or

Cannot invoke Tomcat manager: Software caused connection abort: socket write error

In pom.xml I have this:

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <url>http://localhost:8085/manager/html</url>
        <server>tomcat7</server>
        <path>/java_web</path>
        <username>admin</username>
        <password>admin</password>
    </configuration>
</plugin>

In tomcat-users.xml I have this:

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

Also in Maven/conf/settings.xml I have:

<server>
    <id>tomcat7</id>
    <username>admin</username>
    <password>admin</password>
</server>

When I'm trying to go to

http://localhost:8085/manager/html/deploy?path=%2Fjava_web&update=true

and input username and password (admin admin) I have error:

403 Access Denied
You are not authorized to view this page.

But I typed in tomcat-users.xml that user admin has manager-gui role. I'm using Tomcat 7.0.56 and Jenkins. Also use commands: clean and tomcat7-redeploy. Need help to understand what is wrong:C

Audly answered 14/10, 2014 at 8:52 Comment(0)
H
14

In my case settings looked ok, but I already had the same webapp uploaded to tomcat and hadn't specified

<update>true</update>

in tomcat plugin in pom.xml

Hardnosed answered 6/3, 2016 at 17:53 Comment(3)
see also answer by Melody Feng.Gnarl
Downvote. This is a compilation error. cvc-complex-type.2.4.a: Invalid content was found starting with element 'update'. One of '{"maven.apache.org/POM/4.0.0":extensions, "maven.apache.org/POM/4.0.0":executions, "http:// maven.apache.org/POM/4.0.0":dependencies, "maven.apache.org/POM/4.0.0":goals, "maven.apache.org/POM/4.0.0":inherited}' is expected.Sewage
@PhilipRego probably it should be specified in <configuration> section, thats why you are getting this error. Can't check and tell for sure right now.Hardnosed
A
6

I added

<server>
    <id>tomcat7</id>
    <username>admin</username>
    <password>admin</password>
</server> 

in user/.m2/settings.xml

Also I didn't change pom.xml, tomcat-users.xml and Maven/conf/settings.xml and now all works fine.

Audly answered 5/11, 2014 at 7:46 Comment(3)
I think your problem was the server config in your tomcat maven configuration. It conflicted with the username/password settings. In the pom.xml file you should either remove the <server>tomcat7</server> part, and keep the username and password, or remove the username and password and keep <server>tomcat7</server>.Hafner
location of setings.xml may differ, e.g. could also be: D:\apache-maven-3.3.9\conf\settings.xmlIgnatius
thank you, this is perfect! the server id of maven's settings.xml is corresponding to the server id in pom.xml's tomcat7-maven-plugin server id, or other way round :-) so you can define many servers and keep credentials in one place but refer from many pom.xml's to this.Ignatius
Y
5
        <plugin>
            <!-- tomcat deploy plugin -->
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>tomcat-maven-plugin</artifactId>
            <configuration>
                <url>http://localhost:8080/manager/text</url>
                <server>TomcatServer</server>
                <username>XXXX</username>
                <password>XXXX</password>
                <path>/XXXX</path>
            </configuration>
        </plugin>

This works for me :)

Environment -> Windowd 8.1 + Maven 3 + Tomcat 8.1.15 + JDK 1.8 Also, I had to use tomcat:redeploy

ALso, update your maven settings via -> Preferences->Maven->User Settings to point to your maven settings.xml file. Add the values of the server in the maven settings.xml ( servers section and add the tomcat server details there). Use that here( for me the id is TomcatServer )

Some of the steps were taken from here:- http://kosalads.blogspot.de/2014/03/maven-deploy-war-in-tomcat-7.html

Yippee answered 7/12, 2014 at 22:7 Comment(0)
P
2

Users with the manager-gui role should not be granted either the manager-script or manager-jmx roles.

so,user admin should remove the role "manager-gui"

Patel answered 29/10, 2014 at 2:22 Comment(2)
This was the cause of my "connection being reset" probelm. The admin user was assigned the incorrect role of manager-gui. I added a new manager-script role and a new user and my problem was solved.Sahaptin
Why not? Why shouldn't they have both manager-gui and manager-script?Handhold
D
2
mvn tomcat7:redeploy

try this as documentation suggests:

(Alias for the deploy goal with its update parameter set to true.)

Dagnah answered 4/9, 2015 at 5:24 Comment(1)
Its available since 2.1Shilohshim
F
1

If you have tried again and again to set the users in the tomcat-users.xml file and the error still persists, please consider also checking the permissions of the Tomcat installation and the user that is running the service.

I was experiencing the same errors ("Connection reset by peer: socket write error") until I realized that I had first started the Tomcat server with an administrator / root user and then I was trying to get that server up using another user without administrative privileges. It turns out that in these cases Tomcat is able to start but, logically, it is unable to write to the "webapps" directory to deploy remotely, getting errors similar to those that occur when users have not been configured correctly (same symptoms but different problem).

I had this problem with a Windows Server but I imagine something similar could happen with Linux and MacOS. I leave it here "for posterity" in case it might be of use to anyone else.

Factorize answered 13/10, 2021 at 10:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.