title: Deploying web application to a tomcat server with maven
body: <p>In <strong>pom.xml</strong> i have this for deploying</p>
  
  <pre><code>    &lt;distributionManagement&gt;
          &lt;repository&gt;
              &lt;id&gt;TomcatLocalServer&lt;/id&gt;
              &lt;url&gt;http://localhost:8080/manager&lt;/url&gt;
          &lt;/repository&gt;
      &lt;/distributionManagement&gt;
      &lt;build&gt;
        &lt;plugins&gt;
            &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;tomcat-maven-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;url&gt;http://localhost:8080/manager&lt;/url&gt;
                      &lt;server&gt;TomcatLocalServer&lt;/server&gt;
                      &lt;path&gt;/SCPI&lt;/path&gt;
                  &lt;/configuration&gt;
                  &lt;/plugin&gt;
            &lt;/plugins&gt;
      &lt;/build&gt;
  </code></pre>
  
  <p>In <strong>settings.xml</strong> of tomcat server i have this</p>
  
  <pre><code>        &lt;server&gt;
              &lt;id&gt;TomcatLocalServer&lt;/id&gt;
              &lt;username&gt;andrfas&lt;/username&gt;
              &lt;password&gt;1234&lt;/password&gt;
          &lt;/server&gt;
  </code></pre>
  
  <p>When i'm trying to call maven deploy, i get an error:</p>
  
  <pre><code>Uploading: http://localhost:8080/manager/ua/andrfas/SCPI/0.0.1/SCPI-0.0.1.war
  184/34421 KB   мар 13, 2015 4:04:17 PM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
  INFO: I/O exception (java.net.SocketException) caught when processing request to {}-&gt;http://localhost:8080: Connection reset by peer: socket write error
  мар 13, 2015 4:04:17 PM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
  INFO: Retrying request to {}-&gt;http://localhost:8080
  256/34421 KB   мар 13, 2015 4:04:17 PM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
  INFO: I/O exception (java.net.SocketException) caught when processing request to {}-&gt;http://localhost:8080: Connection reset by peer: socket write error
  мар 13, 2015 4:04:17 PM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
  INFO: Retrying request to {}-&gt;http://localhost:8080
  мар 13, 2015 4:04:17 PM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
  INFO: I/O exception (java.net.SocketException) caught when processing request to {}-&gt;http://localhost:8080: Connection reset by peer: socket write error
  мар 13, 2015 4:04:17 PM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
  INFO: Retrying request to {}-&gt;http://localhost:8080
  Uploading: http://localhost:8080/manager/ua/andrfas/SCPI/0.0.1/SCPI-0.0.1.pom
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project SCPI: Failed to deploy artifacts: Could not transfer artifact ua.andrfas:SCPI:war:0.0.1 from/to TomcatLocalServer (http://localhost:8080/manager): Connection reset by peer: socket write error -&gt; [Help 1]
      org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project SCPI: Failed to deploy artifacts: Could not transfer artifact ua.andrfas:SCPI:war:0.0.1 from/to TomcatLocalServer (http://localhost:8080/manager): Connection reset by peer: socket write error
          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:120)
          at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
          at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
          at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
          at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
          at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
          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)
          at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
          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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
      Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to deploy artifacts: Could not transfer artifact ua.andrfas:SCPI:war:0.0.1 from/to TomcatLocalServer (http://localhost:8080/manager): Connection reset by peer: socket write error
          at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:193)
          at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
          ... 25 more
      Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact ua.andrfas:SCPI:war:0.0.1 from/to TomcatLocalServer (http://localhost:8080/manager): Connection reset by peer: socket write error
          at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:143)
          at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:167)
          at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:157)
          ... 27 more
      Caused by: org.eclipse.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact ua.andrfas:SCPI:war:0.0.1 from/to TomcatLocalServer (http://localhost:8080/manager): Connection reset by peer: socket write error
          at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:317)
          at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:245)
          at org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:413)
          at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:139)
          ... 29 more
      Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact ua.andrfas:SCPI:war:0.0.1 from/to TomcatLocalServer (http://localhost:8080/manager): Connection reset by peer: socket write error
          at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:43)
          at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
          at org.eclipse.aether.connector.basic.BasicRepositoryConnector.put(BasicRepositoryConnector.java:274)
          at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:311)
          ... 32 more
      Caused by: org.apache.maven.wagon.TransferFailedException: Connection reset by peer: socket write error
          at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:662)
          at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:557)
          at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:539)
          at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:533)
          at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:513)
          at org.eclipse.aether.transport.wagon.WagonTransporter$PutTaskRunner.run(WagonTransporter.java:644)
          at org.eclipse.aether.transport.wagon.WagonTransporter.execute(WagonTransporter.java:427)
          at org.eclipse.aether.transport.wagon.WagonTransporter.put(WagonTransporter.java:410)
          at org.eclipse.aether.connector.basic.BasicRepositoryConnector$PutTaskRunner.runTask(BasicRepositoryConnector.java:510)
          at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:350)
          ... 34 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.maven.wagon.providers.http.httpclient.impl.io.SessionOutputBufferImpl.streamWrite(SessionOutputBufferImpl.java:123)
          at org.apache.maven.wagon.providers.http.httpclient.impl.io.SessionOutputBufferImpl.flushBuffer(SessionOutputBufferImpl.java:135)
          at org.apache.maven.wagon.providers.http.httpclient.impl.io.SessionOutputBufferImpl.write(SessionOutputBufferImpl.java:164)
          at org.apache.maven.wagon.providers.http.httpclient.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:115)
          at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon$RequestEntityImplementation.writeTo(AbstractHttpClientWagon.java:204)
          at org.apache.maven.wagon.providers.http.httpclient.impl.DefaultBHttpClientConnection.sendRequestEntity(DefaultBHttpClientConnection.java:155)
          at org.apache.maven.wagon.providers.http.httpclient.impl.conn.CPoolProxy.sendRequestEntity(CPoolProxy.java:149)
          at org.apache.maven.wagon.providers.http.httpclient.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:236)
          at org.apache.maven.wagon.providers.http.httpclient.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:121)
          at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.MainClientExec.execute(MainClientExec.java:254)
          at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
          at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec.execute(RetryExec.java:86)
          at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
          at org.apache.maven.wagon.providers.http.httpclient.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
          at org.apache.maven.wagon.providers.http.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
          at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.execute(AbstractHttpClientWagon.java:848)
          at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:607)
          ... 43 more
  </code></pre>
  
  <p>The server is running.
  I have tried to change tomcat plugin in pom.xml to <em>tomcat7-maven-plugin</em>, but i got the same error.
  As i understand, it's trying to deploy war file to <a href="http://localhost:8080/manager/ua/andrfas/SCPI/0.0.1/SCPI-0.0.1.war" rel="nofollow">http://localhost:8080/manager/ua/andrfas/SCPI/0.0.1/SCPI-0.0.1.war</a>. Is this true? If yes, why?
  What i'm doing wrong?</p>