tags:

views:

259

answers:

2

maven release:perform is failing to distribute via FTP.

The first thing I checked is that I can access the target server with the given credentials from the command line. I can with passive FTP but not with active FTP (known firewall restriction). What I can see from googling is that Maven uses passive FTP by default. Is that correct? If not, how can I cause it to use passive FTP?

Assuming Maven is using passive FTP, I would appreciate any other advice.

My configuration:

settings.xml:

    <servers>
        <server>
            <id>repo-ftp</id>
            <username>myUserName</username>
            <password>myPassword</password>
        </server>
    </servers>

parent POM:

  <distributionManagement>
    <repository>
      <id>repo-ftp</id>
      <url>ftp://myServer</url>
    </repository>
    <snapshotRepository>
      <id>repo-ftp</id>
      <url>ftp://myServer</url>
    </snapshotRepository>
  </distributionManagement>

The error message:

[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] FATAL ERROR
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] org.apache.maven.wagon.AbstractWagon.openConnection()V
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Trace
[INFO] java.lang.AbstractMethodError: org.apache.maven.wagon.AbstractWagon.openConnection()V
[INFO]  at org.apache.maven.wagon.AbstractWagon.connect(AbstractWagon.java:143)
[INFO]  at org.apache.maven.artifact.manager.DefaultWagonManager.putRemoteFile(DefaultWagonManager.java:235)
[INFO]  at org.apache.maven.artifact.manager.DefaultWagonManager.putArtifact(DefaultWagonManager.java:153)
[INFO]  at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:80)
[INFO]  at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:162)
[INFO]  at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:447)
[INFO]  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
[INFO]  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480)
[INFO]  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459)
[INFO]  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
[INFO]  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
[INFO]  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
[INFO]  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:333)
[INFO]  at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
[INFO]  at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
[INFO]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[INFO]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO]  at java.lang.reflect.Method.invoke(Method.java:616)
[INFO]  at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
[INFO]  at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
[INFO]  at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
[INFO]  at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 16 seconds
[INFO] [INFO] Finished at: Wed Oct 21 17:43:11 UTC 2009
[INFO] [INFO] Final Memory: 25M/47M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Maven execution failed, exit code: '1'

UPDATE

I did have an extension node in the parent POM:

<extension>
  <groupId>org.apache.maven.wagon</groupId>
  <artifactId>wagon-ftp</artifactId>
  <version>1.0-beta-5</version>
</extension>

After reviewing the reply from cetnar I realized that I need beta-2 for my particular version of maven. When I switched the extension node to reference beta-2, maven properly complained about not having it available. So, I downloaded and installed using

 mvn install:install-file -DgroupId=org.apache.maven.wagon -DartifactId=wagon-ftp -Dversion=1.0-beta-2 -Dpackaging=jar -Dfile=./wagon-ftp-1.0-beta-2-sources.jar

(which is a cut-and-paste from the error message I got, with my local copy of the .jar in the appropriate location).

Now, I get:

[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] BUILD ERROR
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Error deploying artifact: Unsupported Protocol: 'ftp': Cannot find wagon which supports the requested protocol: ftp
[INFO]
[INFO] Component descriptor cannot be found in the component repository: org.apache.maven.wagon.Wagonftp.

Any advice for that problem?

UPDATE 2

I did not have wagon-ftp.jar or commons-net.jar in $M2_HOME/lib but do now. I get the same error.

$M2_HOME/lib:

commons-cli.jar -> ../../java/commons-cli.jar
commons-net.jar -> ../../java/commons-net.jar
doxia-sink-api.jar -> ../../java/doxia-sink-api.jar
jsch.jar -> ../../java/jsch.jar
jtidy.jar -> ../../java/jtidy.jar
maven2.jar -> ../../java/maven2.jar
plexus-container-default.jar -> ../../java/plexus-container-default.jar
plexus-interactivity-api.jar -> ../../java/plexus-interactivity-api.jar
plexus-utils.jar -> ../../java/plexus-utils.jar
wagon-file.jar -> ../../java/wagon-file.jar
wagon-ftp-1.0-beta-2.jar -> ../../java/wagon-ftp.jar
wagon-ftp.jar -> ../../java/wagon-ftp.jar
wagon-http-lightweight.jar -> ../../java/wagon-http-lightweight.jar
wagon-http-shared.jar -> ../../java/wagon-http-shared.jar
wagon-provider-api.jar -> ../../java/wagon-provider-api.jar
wagon-ssh-common.jar -> ../../java/wagon-ssh-common.jar
wagon-ssh-external.jar -> ../../java/wagon-ssh-external.jar
wagon-ssh.jar -> ../../java/wagon-ssh.jar
xml-apis.jar -> ../../java/xml-apis.jar

Note that all other dependencies were deployed using symbolic links to another directory so I continued the same pattern. Access rights are the same for all files. I tried providing both a wagon-ftp.jar and wagon-ftp-1.0-beta-2.jar symbolic link.

I'm not very excited about the prospect of upgrading to the latest version of maven (for fear of new problems), but is that my best option? Any other ideas?

SOLUTION

It worked! Kind of. Now I get an authentication error, but that's a different issue.

The a-ha moment was the mention of -sources and I realized I had downloaded wagon-ftp-1.0-beta-2-sources.jar but installed with -Dversion=1.0-beta-2 (no -sources)... so I copied the sources JAR to the binary jar file name :-).

Thank you all for your help with this!

+1  A: 

Did you define wagon-ftp as a extension in your pom?

<extensions>
  <extension>
    <groupId>org.apache.maven.wagon</groupId>
    <artifactId>wagon-ftp</artifactId>
    <version>1.0-alpha-3</version>
  </extension>
</extensions>

If yes I thing the problem is in wrong versions maven and wagon-ftp. Here is one article about this problem.

In maven-user-list I found that you need to use 1.0-beta-2 of the ftp wagon with 2.0.9. 1.0-beta-3 will work with 2.0.10 and Wagon 1.0-beta-5 release will only work as an extension in Maven 2.1.0-M1 and above.

cetnar
AFAIK, 1.0-beta-3+ does not work with Maven 2.0.x
Pascal Thivent
My maven version is 2.0.9. Changed to use beta-2 but get a new error, which I have appended to my original question.
Eric J.
@Pascal. I found this statement in one of Brett Porter responses in maven-user-list, I didn't check this configuration.
cetnar
@cetnar From the same Brett Porter: http://jira.codehaus.org/browse/WAGON-266 :)
Pascal Thivent
+1  A: 

The setup looks good. And yes, passive mode is the default (see WAGON-143). That said, according to the trace (java.lang.AbstractMethodError is thrown when something tries to call an abstract method), it's obvious that your wagon isn't compatible with your version of maven. Wagon madness...

It's surely not the best place but this is actually documented in the Guide to using Extenstions (pay a special attention to the "Note" at the bottom):

Extensions are used to enable Wagon providers, used for the transport of artifact between repositories, and plug-ins which provide lifecycle enhancements. Wagon providers

<project>
  ...
  <build>
    <extensions>
      <extension>
        <groupId>org.apache.maven.wagon</groupId>
         <artifactId>wagon-ftp</artifactId>
         <version>1.0-beta-2</version>
      </extension>
    </extensions>
  </build>
  ...
</project>

Note: Wagon 1.0-beta-3+ requires Maven 2.1.0 or above. For Maven 2.0.10 and earlier, use Wagon 1.0-beta-2.

EDIT: About the new error, the maven deploy plugin FAQ describes something very similar:

If you are using the deploy:deploy-file goal and encounter this error:

"Error deploying artifact: Unsupported Protocol: 'ftp': Cannot find wagon which supports the requested protocol: ftp"

Then you need to place the appropriate wagon provider in your %M2_HOME%/lib. In this case the provider needed is ftp, so we have to place the wagon-ftp jar in the lib directory of your Maven 2 installation.

If the error description is something like this:

"Error deploying artifact: Unsupported Protocol: 'ftp': Cannot find wagon which supports the requested protocol: ftp org/apache/commons/net/ftp/FTP"

Then you need to place the commons-net jar in %M2_HOME%/lib.

I don't get why one would have to do that but try to put wagon-ftp-1.0-beta-2.jar in %M2_HOME%/lib.

EDIT2: I've read the question again and it looks like you did install a "sources" jar which, of course, doesn't contain the required classes for the runtime. Before following the advice above, try to put wagon-ftp-1.0-beta-2.jar in your repository (and not wagon-ftp-1.0-beta-2-sources.jar).

Pascal Thivent