mavenwagon

Maven error when i try to run it using mvn -e -X deploy using wagon SCP


I am trying to copy the resources to a server using scp with wagon.

What is the purpose of adding repository under distributionManagement?

My pom.xml looks like this

<distributionManagement>
            <repository>
                <id>iq</id>
                <url>ftp://server:port</url>
            </repository>
</distributionManagement>
<build>
    <extensions>
        <extension>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-ftp</artifactId>
            <version>1.0-beta-6</version>
        </extension>
    </extensions>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>wagon-maven-plugin</artifactId>
            <version>1.0-beta-3</version>
             <extensions>true</extensions>
            <executions>
                <execution>
                    <phase>deploy</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <serverId>iq</serverId>
                        <fromDir>src/main/webapps</fromDir>
                        <url>scp:ftp://server:port</url>
                        <toDir>.iq/resources/</toDir>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>

And my settings.xml file is

<servers>
    <server>
      <id>iq</id>
      <username>user</username>
      <password>pass</password>      
    </server>
</servers>

*Error is *

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project iq-resources: Failed to deploy artifacts: Could not transfer artifact test.com.test:resources:jar:2.50.6.a from/to iq (ftp://server:port): Could not connect to server. Could not parse response code.
[ERROR] Server Reply: SSH-2.0-OpenSSH_4.3
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project iq-resources: Failed to deploy artifacts: Could not transfer artifact test.com.test:resources:jar:2.50.6.a from/to  (ftp://server:port): Could not connect to server.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    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:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to deploy artifacts: Could not transfer artifact :resources:jar:2.50.6.a from/to iq (ftp://server:port): Could not connect to server.
    at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:189)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact resources:jar:2.50.6.a from/to iq (ftp://server:port): Could not connect to server.
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:140)
    at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:156)
    ... 21 more
Caused by: org.sonatype.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact resources:jar:2.50.6.a from/to iq (ftp://server:port): Could not connect to server.
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:259)
    at org.sonatype.aether.impl.internal.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:380)
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:136)
    ... 22 more
Caused by: org.sonatype.aether.transfer.ArtifactTransferException: Could not transfer artifact  resources:jar:2.50.6.a from/to iq (ftp://server:port): Could not connect to server.
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:949)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:940)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.flush(WagonRepositoryConnector.java:864)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:465)
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:253)
    ... 24 more
Caused by: org.apache.maven.wagon.authentication.AuthenticationException: Could not connect to server.
    at org.apache.maven.wagon.providers.ftp.FtpWagon.openConnectionInternal(FtpWagon.java:154)
    at org.apache.maven.wagon.AbstractWagon.openConnection(AbstractWagon.java:105)
    at org.apache.maven.wagon.AbstractWagon.connect(AbstractWagon.java:207)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.connectWagon(WagonRepositoryConnector.java:326)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.pollWagon(WagonRepositoryConnector.java:366)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:817)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:464)
    ... 25 more
Caused by: org.apache.commons.net.MalformedServerReplyException: Could not parse response code.
Server Reply: SSH-2.0-OpenSSH_4.3
    at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:315)
    at org.apache.commons.net.ftp.FTP._connectAction_(FTP.java:364)
    at org.apache.commons.net.ftp.FTPClient._connectAction_(FTPClient.java:540)
    at org.apache.commons.net.SocketClient.connect(SocketClient.java:178)
    at org.apache.maven.wagon.providers.ftp.FtpWagon.openConnectionInternal(FtpWagon.java:119)
    ... 31 more
[ERROR] 
[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

Solution

  • ftp and scp are two different protocols. The error is because you are trying to use wagon-ftp library to do scp.

    First check what exactly is the server that you have - ftp or scp. If ftp, you may want to remove scp from the url. If scp, then you may want to use wagon-ssh library.

    Also refer to wagon documentation for the various transport abstractions.