When I am trying to run mvn dependency:tree , I am getting : java.lang.NoClassDefFoundError: org/sonatype/aether/version/VersionConstraint
I have no idea why this is happening. I tried deleting my m2 repository as well.
I tried with various versions of maven plugins(2.8) as well.
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
</dependency>
Here is the complete stacktrace :
Error injecting: org.apache.maven.shared.dependency.graph.internal.Maven3DependencyGraphBuilder
java.lang.NoClassDefFoundError: org/sonatype/aether/version/VersionConstraint
at java.lang.Class.getDeclaredMethods0 (Native Method)
at java.lang.Class.privateGetDeclaredMethods (Class.java:2701)
at java.lang.Class.getDeclaredMethods (Class.java:1975)
at com.google.inject.spi.InjectionPoint.getDeclaredMethods (InjectionPoint.java:766)
at com.google.inject.spi.InjectionPoint.getInjectionPoints (InjectionPoint.java:683)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields (InjectionPoint.java:378)
at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies
(ConstructorBindingImpl.java:181)
Caused by: java.lang.ClassNotFoundException: org.sonatype.aether.version.VersionConstraint
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass (ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:239)
at java.lang.Class.getDeclaredMethods0 (Native Method)
at java.lang.Class.privateGetDeclaredMethods (Class.java:2701)
at java.lang.Class.getDeclaredMethods (Class.java:1975)
at com.google.inject.spi.InjectionPoint.getDeclaredMethods (InjectionPoint.java:766)
at com.google.inject.spi.InjectionPoint.getInjectionPoints (InjectionPoint.java:683)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields (InjectionPoint.java:378)
Update Maven version, at least to 3.0.x+ or 3.1.x+ see here
This error is caused by Maven 3.1-alpha-1 migration from Sonatype Aether to Eclipse Aether (MNG-5354), which is an incompatible change for some plugins.
Other report here claim to use Maven 3.3.0, so in any case, try with latest stable maven first (you can get it from here)
Side question: are you developing maven plugin? Usually you shouldn't declare dependencies on plugins in your pom.xml