23

I am trying deploy a web application to tomcat7 via eclipse luna, but I am getting this error:

Uploading: http://localhost:8080/manager/text/deploy?path=%2Floja

[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Floja

[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Floja

[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Floja

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.936 s
[INFO] Finished at: 2014-08-15T22:10:04-03:00
[INFO] Final Memory: 13M/112M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project loja: Cannot invoke Tomcat manager: Connection reset -> [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

I also try deploy to tomcat8, but I get this same error.

In my pom.xml, I have this configuration related to this operation:

  <build>
    <finalName>loja</finalName>
    <plugins>
        <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>
                <path>/loja</path>
                <username>user001</username>
                <password>123</password>
           </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
</build>

Anyone knows what's happening here?

UPDATE

I try deploy the application with the command mvn:tomcat7 deploy -X and the output was that:

[INFO] Retrying request
[DEBUG] Reopening the direct connection.
[DEBUG] Connecting to localhost:8080
[DEBUG] Attempt 4 to execute request
[DEBUG] Sending request: PUT /manager/text/deploy?path=%2Floja HTTP/1.1
[DEBUG]  >> "PUT /manager/text/deploy?path=%2Floja HTTP/1.1[\r][\n]"
[DEBUG]  >> "User-Agent: Apache Tomcat Maven Plugin/2.2[\r][\n]"
[DEBUG]  >> "Content-Length: 18783041[\r][\n]"
[DEBUG]  >> "Host: localhost:8080[\r][\n]"
[DEBUG]  >> "Connection: Keep-Alive[\r][\n]"
[DEBUG]  >> "Authorization: Basic dXNlcjAwMToxMjM=[\r][\n]"
[DEBUG]  >> "[\r][\n]"
[DEBUG] >> PUT /manager/text/deploy?path=%2Floja HTTP/1.1
[DEBUG] >> User-Agent: Apache Tomcat Maven Plugin/2.2
[DEBUG] >> Content-Length: 18783041
[DEBUG] >> Host: localhost:8080
[DEBUG] >> Connection: Keep-Alive
[DEBUG] >> Authorization: Basic dXNlcjAwMToxMjM=
Uploading: http://localhost:8080/manager/text/deploy?path=%2Floja
...
[DEBUG] Connection 0.0.0.0:53183<->127.0.0.1:8080 closed
[DEBUG] Closing the connection.
[DEBUG] Connection 0.0.0.0:53183<->127.0.0.1:8080 closed
[DEBUG] Connection 0.0.0.0:53183<->127.0.0.1:8080 shut down
[DEBUG] Connection 0.0.0.0:53183<->127.0.0.1:8080 closed
[DEBUG] Connection released: [id: 0][route: {}->http://localhost:8080][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 5]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.271 s
[INFO] Finished at: 2014-08-16T08:11:09-03:00
[DEBUG] Connection manager is shutting down
[INFO] Final Memory: 14M/109M
[INFO] ------------------------------------------------------------------------
[DEBUG] Connection manager shut down
Kleber Mota
  • 8,521
  • 31
  • 94
  • 188
  • The `url` is rigth?, normally is `http://localhost:8080/manager/` – Arturo Volpe Aug 16 '14 at 01:41
  • @AVolpe yes. it's right. I was deploying without problem with the eclipse kepler, when I update to luna the error started. – Kleber Mota Aug 16 '14 at 01:55
  • Try to run **mvn tomcat7:..... -X** to get more information about the problem – Skizzo Aug 16 '14 at 07:46
  • @Skizzo Ok, I try this way and the message was added to the question (see update). it has a stacktrace too, but i don't have space to post. the last one was `Caused by: java.net.SocketException: Connection reset` – Kleber Mota Aug 16 '14 at 11:17
  • I believe the url should be `http://localhost:8080/manager/html` and remove the forward slash in path – Karthik Prasad Aug 16 '14 at 11:24
  • @KarthikPrasad No, this url open the graphical version of the manager (via browser). the url used here is for access via command line. I use the url `localhost:8080/manager/text` without problem in version kepler of the eclipse. When i update to luna, don't work anymore. – Kleber Mota Aug 16 '14 at 11:34
  • Does anybody has a solution for this ? Off course debug mode doesn't say more. – christophenoel Sep 25 '14 at 11:14

11 Answers11

21

By default Tomcat has a max upload size of 50MB. (I.e max size of WAR file)

If you require larger file, try increasing max-file-size and max-request-size within the tomcat web.xml. Note: those values are both stored in bytes.

Edit .../webapps/manager/WEB-INF/web.xml. (Ensure the file sizes are larger than the war file your trying to upload). I.e if you require 80MB WAR,

  <max-file-size>82914560</max-file-size>
  <max-request-size>82914560</max-request-size>

Then restart apache tomcat.

https://octopus.com/blog/tomcat-manager-deployment

wired00
  • 13,930
  • 7
  • 70
  • 73
19

Ok, I had the same issue with tomcat7.

[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2iplover

[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2iplover

[INFO] I/O exception (java.net.SocketException) caught when processing request:         Connection reset
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2iplover

I could not get it to work with

mvn tomcat7:redeploy 

as mentioned here.

My WAR wasn't very large, just 4MB.

Here was the root problem and solution

It is important that your tomcat-users.xml has the correct roles setup. I ONLY had the role manager setup. Adding manager-script seems important and completely solved my problem.

<role rolename="manager"/>
<role rolename="manager-script"/>
<role rolename="manager-gui"/>
<user username="admin" password="admin" roles="manager,manager-gui,manager-script"/>
Community
  • 1
  • 1
lawinslow
  • 961
  • 6
  • 12
12

I don't know if anybody solved this issue. I have found a workaround in my case: use of redeploy instead of deploy works fine.

The issue may perhaps be related to memory issue or read/write access isn't it ?

christophenoel
  • 308
  • 3
  • 8
  • It worked for me : Sumits-MacBook-Pro:TestService eSumit$ mvn tomcat7:redeploy -X, Received : [INFO] tomcatManager status code:200, ReasonPhrase:OK – Sumit Arora Oct 02 '15 at 18:32
10

What's the size of your war? maybe it is because the size too large. By default, tomcat manager only allow less then 50MB size war. also try mvn tomcat7:redeploy instead of deploy.

See here how to increase the war size limit

Gonen
  • 4,005
  • 1
  • 31
  • 39
Wei
  • 101
  • 2
7

I was having the same issue and solved it by running the maven goal

tomcat7:redeploy

instead of

tomcat7:deploy

It worked for both tomcat7 and tomcat8, and my war file was always below 50mb.

cleberz
  • 601
  • 7
  • 11
2

Check ~/.m2/settings.xml

<settings>
  <servers>
    <server>
      <id>tomcat-manager</id>
      <username>user001</username>
      <password>123</password>
    </server>
  </servers>
</settings>
masniimura
  • 21
  • 1
2

I've had the same issue and in my case the problem was a cunfigured context path not starting with /. Fixing the context path "myapp" to "/myapp" solved the problem.

Frank
  • 741
  • 1
  • 10
  • 24
2

Occasionally problems

If sometimes the redeployment fails, sometimes succeed, a increase of the logging might show a DOS protection.

Edit the /conf/logging.properties and add the line

org.apache.catalina.level = FINEST

At the end of the file. Might show this output:

FINE [http-nio-8080-exec-7] org.apache.catalina.authenticator.AuthenticatorBase.invoke Security checking request PUT /manager/text/deploy
FINE [http-nio-8080-exec-7] org.apache.catalina.loader.WebappClassLoaderBase.loadClass loadClass(org.apache.catalina.manager.ManagerServlet, false)
FINE [http-nio-8080-exec-7] org.apache.catalina.loader.WebappClassLoaderBase.loadClass   Delegating to parent classloader1 java.net.URLClassLoader@568db2f2
FINE [http-nio-8080-exec-7] org.apache.catalina.loader.WebappClassLoaderBase.loadClass   Loading class from parent
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[Status interface]' against PUT /text/deploy --> false
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[Text Manager interface (for scripts)]' against PUT /text/deploy --> true
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[HTML Manager interface (for humans)]' against PUT /text/deploy --> false
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[JMX Proxy interface]' against PUT /text/deploy --> false
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[Status interface]' against PUT /text/deploy --> false
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[Text Manager interface (for scripts)]' against PUT /text/deploy --> true
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[HTML Manager interface (for humans)]' against PUT /text/deploy --> false
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[JMX Proxy interface]' against PUT /text/deploy --> false
FINE [http-nio-8080-exec-7] org.apache.catalina.authenticator.AuthenticatorBase.invoke  Calling hasUserDataPermission()
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.hasUserDataPermission   User data constraint has no restrictions
FINE [http-nio-8080-exec-7] org.apache.catalina.authenticator.AuthenticatorBase.invoke  Calling authenticate()
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.CombinedRealm.authenticate Attempting to authenticate user [admin] with realm [org.apache.catalina.realm.UserDatabaseRealm]
FINER [http-nio-8080-exec-7] org.apache.catalina.realm.RealmBase.authenticate Username [admin] NOT successfully authenticated
FINE [http-nio-8080-exec-7] org.apache.catalina.realm.CombinedRealm.authenticate Failed to authenticate user [admin] with realm [org.apache.catalina.realm.UserDatabaseRealm]
WARNING [http-nio-8080-exec-7] org.apache.catalina.realm.LockOutRealm.filterLockedAccounts 
     An attempt was made to authenticate the locked user [admin]
FINE [http-nio-8080-exec-7] org.apache.catalina.authenticator.AuthenticatorBase.invoke  Failed authenticate() test
FINE [http-nio-8080-exec-7] org.apache.catalina.core.StandardHostValve.custom Processing ErrorPage[errorCode=401, location=/WEB-INF/jsp/401.jsp]
FINER [http-nio-8080-exec-7] org.apache.catalina.core.StandardWrapper.allocate   Returning non-STM instance
FINE [http-nio-8080-exec-7] org.apache.catalina.core.ApplicationDispatcher.doForward  Disabling the response for further output

(in this logging the user who made the attempt to upload has the username admin)

As you see in this output the user admin is locked:

WARNING [http-nio-8080-exec-7] org.apache.catalina.realm.LockOutRealm.filterLockedAccounts 
  An attempt was made to authenticate the locked user [admin]

Look into the documentation and inside the server.xml and you will find a

   <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
           resourceName="UserDatabase"/>

Use unforseeable username

To remove the line is a bad idea, change the username for redeployment to a different, more unforeseeable name like deploy355547511 to not get locked.

Grim
  • 1,938
  • 10
  • 56
  • 123
  • How do I change the username from `admin` to something else, like `deploy` when deploying the WAR files to Tomcat? – tom_mai78101 Jan 26 '20 at 19:35
  • @tom_mai78101 Yes, your question is absolutly justified! You will find the `conf/tomcat-users.xml` file. By default this file is empty because of security reasons. If you read the comments in the `tomcat-users.xml` carefully you will become aware of a combination of username, password and role and you will ask another question: **What is the role the manager-app uses for deployments?**! The solution to this question is part of the manager-app's `web.xml`. – Grim Jan 26 '20 at 21:45
  • I know what to do now, and I got my specific problem fixed. I modified `conf/tomcat-users.xml` but I still get `admin` as the username, hinting to me that there may be more to this. I wasn't sure, until I realized this is a Maven 2 Eclipse (m2e) specific settings where Maven would use the default, `admin`, unless you tell m2e to use a different username and password when deploying. I had to add a `settings.xml` inside `/home/username/.m2/` directory. – tom_mai78101 Jan 27 '20 at 02:54
  • @tom_mai78101 You do not have to use `settings.xml`, you can override the deploy-username by `-Dtomcat.username=xxx`. – Grim Jan 27 '20 at 13:51
2

(Re-)deploy with the Maven tomcat plugin failed for me too with a connection reset on the client and 403 status code in the localhost_access.log on Tomcat 8.5.30.

This Tomcat version's manager app has a RemoteAddrValve configured by default, restricting access to the /manager/* path to localhost. See $TOMCAT_HOME/webapps/manager/META-INF/context.xml.

It helped to turn on the logging to find the solution to this.

KahPhi
  • 73
  • 2
  • 8
0

I dont know if this helps , But in My case . tomcat7 plugin was picking server details from the maven conf settings.xml instead room .m2\settings.xml . Adding server information in that file Resolved my Issue .

0

In my case on my AWS amazon instance the reason was:

The Disk Space Was FULL note 99% on my EC2 spot instance

Am using jenkins using this command normally

 mvn clean tomcat7:redeploy -Ddeploy.password=xxxAG1
 -Ddeploy.username=admin -Ddeploy.context=/v1 -Ddeploy.url=http://localhost:8080/manager/text

enter image description here

Just Free that space and it worked with me.

The Error i had is

[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset
[INFO] Retrying request


[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 53.914 s
[INFO] Finished at: 2018-01-10T08:38:28+00:00
[INFO] Final Memory: 47M/371M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:redeploy (default-cli) on project XXXX-app: Cannot invoke Tomcat manager: Connection reset -> [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.

Hint use this command to track down what is eating your space from ( command is from stackoverflow ) sudo du -x -d1 -h /

shareef
  • 9,255
  • 13
  • 58
  • 89