1

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)
GKr297
  • 185
  • 2
  • 16
  • A maven plugin as dependency is simply wrong. Define a plugin in pluginManagement instead. Also show the command you have used and which JDK version, Maven version etc. you have used. – khmarbaise Oct 28 '20 at 10:51
  • I don't need a maven plugin , so I removed it. I am using mvn dependency:tree , jdk 11.0.5 and maven 3.5.4 – GKr297 Oct 28 '20 at 11:00
  • 1
    Which version of maven-dependency-plugin have you used cause it is not part of the error output ...which is usually logged out ... best would be to use `mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.2:tree` to be sure to use the most recent version of the plugin.... – khmarbaise Oct 28 '20 at 11:52

2 Answers2

2

You can solve by using an older version of the plugin as indicated by the official page recalled by the error log:

mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:tree
Alessandro Argentieri
  • 2,901
  • 3
  • 32
  • 62
1

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

rkosegi
  • 14,165
  • 5
  • 50
  • 83
  • I am not developing any maven plugin.. I just found it somewhere while I was searching online to resolve this issue – GKr297 Oct 28 '20 at 10:35
  • @GKr297 you have version mismatch between some of plugins you are using and maven runtime. Update to latest versions where possible – rkosegi Oct 28 '20 at 15:31