java.lang.ClassNotFoundException: org.sonatype.aether.version.InvalidVersionSpecificationException

28.5k Views Asked by At

I am using the maven indexer to fetch the maven index from the maven central repository. Since I updated from org.sonatype.aether to org.eclipse.aether and from maven 3.0.5 to maven 3.1.0 I am getting this Exception.

Caused by: java.lang.ClassNotFoundException: org.sonatype.aether.version.InvalidVersionSpecificationException
    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)

Maven tells me that I should check out this page: http://cwiki.apache.org/confluence/display/MAVEN/AetherClassNotFound. Did that. But on the page they just say that they are aware of this problem and they updated some maven plugins to run with maven 3.1.0. But they don't say what is the problem and how to solve it. That is not very useful. What I have to change to make my own plugin work with maven 3.1.0 ???

I double checked my dependencies with:

mvn dependency:tree

And it seems that the old org.sonatype.aether.aether-api.jar is still in the project, which contains the Exception. So basically the org.sonatype.aether.version.InvalidVersionSpecificationException is part of my project. So why do I get this Exception ??

3

There are 3 best solutions below

0
On

Converting my previous comment into an answer, you can use:

mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:tree

Naturally, you can specify any version.

2
On

This error is caused by the Maven 3.1-alpha-1 migration from Sonatype Aether to Eclipse Aether, which is an incompatible change for some plugins.

To support this change, new versions of the affected plugins have been published which work both with Maven 3.0.x and 3.1.x. A list of affected plug-ins and their minimum needed version is available at https://cwiki.apache.org/confluence/display/MAVEN/AetherClassNotFound

5
On

Use a later version of maven-dependency-plugin.

<plugin>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.8</version>
    .... your configuration here ....
</plugin>