2

I am getting a strange error from the maven dependency plugin for all of the projects that I am trying to build:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:copy (get-native-libs) on project tradestp-parent: Unable to parse configuration of mojo org.apache.maven.plugins:ma ven-dependency-plugin:2.8:copy: Error loading class 'org.apache.maven.plugin.dependency.fromConfiguration.Artifact' -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:copy (get-native-libs) on project tradestp-parent: Unable to parse c onfiguration of mojo org.apache.maven.plugins:maven-dependency-plugin:2.8:copy: Error loading class 'org.apache.maven.plugin.dependency.fromConfiguration.Artifact'
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
    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:316)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:451)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:188)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:134)
    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.PluginConfigurationException: Unable to parse configuration of mojo org.apache.maven.plugins:maven-dependency-plugin:2.8:copy: Error loading class 'org.apache.maven.  plugin.dependency.fromConfiguration.Artifact'
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:564)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:496)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:96)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
    ... 19 more
Caused by: org.codehaus.plexus.component.configurator.ComponentConfigurationException: Error loading class 'org.apache.maven.plugin.dependency.fromConfiguration.Artifact'
    at org.codehaus.plexus.component.configurator.converters.composite.CollectionConverter.fromConfiguration(CollectionConverter.java:174)
    at org.codehaus.plexus.component.configurator.converters.ComponentValueSetter.configure(ComponentValueSetter.java:218)
    at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:137)
    at org.codehaus.plexus.component.configurator.BasicComponentConfigurator.configureComponent(BasicComponentConfigurator.java:56)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:534)
    ... 22 more
Caused by: java.lang.ClassNotFoundException: org.apache.maven.plugin.dependency.fromConfiguration.Artifact
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
    at org.codehaus.plexus.component.configurator.converters.composite.CollectionConverter.fromConfiguration(CollectionConverter.java:161)
    ... 26 more

The strange thing is that the class it is looking for org.apache.maven.plugin.dependency.fromConfiguration.Artifact really does not exist and never has.

Has anyone seen this problem before? Why is the maven dependency plugin trying to load a non-existent class?

1
  • What version of Maven is this? Could you please paste your pom.xml? Commented May 23, 2014 at 15:03

1 Answer 1

1

Not sure if you're still having this problem, but I just ran into the same issue.

In our case we were using the copy goal to copy a dependency. The pom was as follows:

<plugin>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>copy-custom-artifact</id>
            <goals>
                <goal>copy</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifact>
                        <groupId>some.artifact.groupid</groupId>
                        <artifactId>some.artifact.artifactid</artifactId>
                    </artifact>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>

I found the following answer to a different question, which stated the following:

The unpack and copy goals have to replicate some of the core resolution code. Unfortunately that resolution code was not really in a useable form api-wise. Because of this, those goals do not handle version ranges, and also don't resolve artifacts directly from the reactor (I frankly just never implemented them because it broke too many of the existing use cases, yeah core the resolution code was that bad)

A much better approach is to use the xxx-dependencies forms of these goals.

Based on this I changed our pom to use the copy-depenencies goal, as follows:

<plugin>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>copy-custom-artifact</id>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
            <configuration>
                <includeArtifactIds>some.artifact.artifactid</includeArtifactIds>
            </configuration>
        </execution>
    </executions>
</plugin>

After this change, the build was successful. Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.