2015-03-13 320 views
1

pom.xml中我有這樣的部署部署Web應用程序到Tomcat服務器使用Maven

<distributionManagement> 
     <repository> 
      <id>TomcatLocalServer</id> 
      <url>http://localhost:8080/manager</url> 
     </repository> 
    </distributionManagement> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>tomcat-maven-plugin</artifactId> 
       <configuration> 
        <url>http://localhost:8080/manager</url> 
        <server>TomcatLocalServer</server> 
        <path>/SCPI</path> 
       </configuration> 
       </plugin> 
      </plugins> 
    </build> 

在Tomcat服務器中的的settings.xml我有這個

 <server> 
      <id>TomcatLocalServer</id> 
      <username>andrfas</username> 
      <password>1234</password> 
     </server> 

當我試圖調用maven部署,我得到一個錯誤:

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 {}->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 {}->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 {}->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 {}->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 {}->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 {}->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 -> [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 

服務器正在運行。 我試圖將pom.xml中的tomcat插件更改爲tomcat7-maven-plugin,但我得到了同樣的錯誤。 據我所知,它試圖部署戰爭檔案http://localhost:8080/manager/ua/andrfas/SCPI/0.0.1/SCPI-0.0.1.war。這是真的?如果是,爲什麼? 我做錯了什麼?

回答

4

所以,這裏是我的問題的解決方案:

改變了插件tomcat7 - Maven的插件:

<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>TomcatLocalServer</server> 
        <path>/SCPI</path> 
        <username>andrfas</username> 
        <password>1234</password> 
        <update>true</update> 
       </configuration> 
      </plugin> 

記錄URL - http://localhost:8080/manager/text,不http://localhost:8080/manager/html

在tomcat-users.xml中添加了

<user username="andrfas" password="1234" roles="manager-script"/> 

請注意角色 - 經理腳本,而不是經理gui。

最後,根據上面列出的插件運行mvn tomcat7:deploy。只是要小心運行正確版本的插件。

+1

您也可以使用maven貨物插件來部署您的應用程序。這裏是鏈接:http://www.java-tutorial.ch/maven/maven-tomcat-deployment-using-cargo – dogankadriye 2015-03-16 15:03:35

相關問題