Thursday, March 11, 2010

Solving Maven Deploy/Release Problem: Unsupported Protocol: 'dav': Cannot find wagon which supports the requested protocol: dav

Are you getting the following error while using Maven and Release/Deploy Plugin on a WebDAV repository?
[INFO] [INFO] [deploy:deploy {execution: default-deploy}]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] BUILD ERROR
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Error deploying artifact: Unsupported Protocol: 'dav': Cannot find wagon which supports the requested protocol: dav
[INFO]
[INFO] Component descriptor cannot be found in the component repository: org.apache.maven.wagon.Wagondav.
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] For more information, run Maven with the -e switch
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 7 seconds
[INFO] [INFO] Finished at: Fri Mar 12 01:01:37 WIT 2010
[INFO] [INFO] Final Memory: 20M/74M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Maven execution failed, exit code: '1'

[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Maven execution failed, exit code: '1'
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    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.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Maven execution failed, exit code: '1'
    at org.apache.maven.plugins.release.PerformReleaseMojo.execute(PerformReleaseMojo.java:133)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    ... 17 more
Caused by: org.apache.maven.shared.release.ReleaseExecutionException: Maven execution failed, exit code: '1'
    at org.apache.maven.shared.release.phase.AbstractRunGoalsPhase.execute(AbstractRunGoalsPhase.java:89)
    at org.apache.maven.shared.release.phase.RunPerformGoalsPhase.execute(RunPerformGoalsPhase.java:67)
    at org.apache.maven.shared.release.DefaultReleaseManager.perform(DefaultReleaseManager.java:334)
    at org.apache.maven.shared.release.DefaultReleaseManager.perform(DefaultReleaseManager.java:282)
    at org.apache.maven.shared.release.DefaultReleaseManager.perform(DefaultReleaseManager.java:262)
    at org.apache.maven.plugins.release.PerformReleaseMojo.execute(PerformReleaseMojo.java:129)
    ... 19 more
Caused by: org.apache.maven.shared.release.exec.MavenExecutorException: Maven execution failed, exit code: '1'
    at org.apache.maven.shared.release.exec.InvokerMavenExecutor.executeGoals(InvokerMavenExecutor.java:375)
    at org.apache.maven.shared.release.exec.InvokerMavenExecutor.executeGoals(InvokerMavenExecutor.java:393)
    at org.apache.maven.shared.release.phase.AbstractRunGoalsPhase.execute(AbstractRunGoalsPhase.java:81)
    ... 24 more

Cause


If you have an old version of Maven, this is a known problem as the DAV wagon was not built in. Upgrade to the latest Maven version first (Maven 2.2.1 and later).

If you have a newer version of Maven, you might be using Debian or Ubuntu, which contains an incomplete version of Maven, that doesn't include the DAV wagon (wagon-webdav-jackrabbit).

Solution


Add this to your POM :
    <build>
        <extensions>
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-webdav-jackrabbit</artifactId>
                <version>1.0-beta-6</version>
            </extension>
        </extensions>
    </build>
Tip: For Maven Release Plugin, you might want to use version 2.0.
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.0</version>
            </plugin>
        </plugins>
    </build>
In multi-module project, theoretically you just need to put this in the super POM. But I haven't checked it, it may not work on child modules. If so, add the "extension" part on all POMs that require deploying to a WebDAV repository server.

For in-depth information about Maven, get Apache Maven 2 Effective Implementation book.

2 comments:

  1. Thanks for the tip. Strangely, it works for "mvn deploy" but not "mvn release:perform". This is on Ubuntu 9.10 (Karmic Koala) with Maven 2.2.1 and Sun Java 1.6.0_20.

    ReplyDelete
  2. For using mvn release:perform I have uninstall the ubuntu package maven2 and download maven2 from http://maven.apache.org/

    ReplyDelete