1

I'm getting java.lang.NoSuchMethodException: jdk.internal.module.ModuleReferenceImpl.descriptor() error while executing mvn clean intall in my intellij IDE.

It's started to happen when I downgraded my jdk-11.0.2 to jdk1.8.0_191.

here is the complete stackTrace:

   java.lang.NoSuchMethodException: jdk.internal.module.ModuleReferenceImpl.descriptor()
    at java.base/java.lang.Class.getDeclaredMethod(Class.java:2476)
    at org.apache.maven.plugins.dependency.utils.DependencyStatusSets.getModuleDescriptor(DependencyStatusSets.java:272)
    at org.apache.maven.plugins.dependency.utils.DependencyStatusSets.buildArtifactListOutput(DependencyStatusSets.java:227)
    at org.apache.maven.plugins.dependency.utils.DependencyStatusSets.getOutput(DependencyStatusSets.java:165)
    at org.apache.maven.plugins.dependency.resolvers.ResolveDependenciesMojo.doExecute(ResolveDependenciesMojo.java:90)
    at org.apache.maven.plugins.dependency.AbstractDependencyMojo.execute(AbstractDependencyMojo.java:143)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

and my mvn version details are here :

Admins-MacBook-Pro:carot jangbahadurpatel$ mvn --version
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T00:11:47+05:30)
Maven home: /usr/local/Cellar/maven/3.6.0/libexec
Java version: 11.0.2, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.1", arch: "x86_64", family: "mac"

What to do to figure it out?

Jabongg
  • 2,099
  • 2
  • 15
  • 32
  • Please share the exact `mvn -version` and the phase where this fails. Also, your maven configurations would help here to reproduce this. – Naman Jan 17 '19 at 06:06
  • @nullpointer I have updated my question with mvn version. – Jabongg Jan 17 '19 at 06:12
  • Seems like your maven is configured with `Java11` while you're trying to compile code with `Java-8` instead. Details of configurations in `pom.xml` could clarify I believe. – Naman Jan 17 '19 at 06:15
  • I can't see java related configuration in my pom.xml. It's all jersey, spring-web and other dependencies but not java or jdk related configuration. – Jabongg Jan 17 '19 at 06:19
  • Then some defaults would be getting used, just go through the maven output on your console. It displays the versions of the plugins used. You could possibly find an incompatible version there. – Naman Jan 17 '19 at 06:21
  • should I un-install jdk-11 and jdk-8 and retry with jdk-8 ? – Jabongg Jan 17 '19 at 06:22
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/186829/discussion-between-jabongg-and-nullpointer). – Jabongg Jan 17 '19 at 06:22
  • 2
    Not precisely, you can configure your `mavenrc` to use JDK8 for you or else ensure there is proper `toolchains.xml` present in your maven configuration. https://maven.apache.org/guides/mini/guide-using-toolchains.html – Naman Jan 17 '19 at 06:42
  • mavenrc example - https://stackoverflow.com/questions/46118716/fatal-error-compiling-invalid-flag-module-path/46119209#46119209 – Naman Jan 17 '19 at 06:45

1 Answers1

0

What it's started to happen when I downgraded my jdk-11.0.2 to jdk1.8.0_191.

This + java.lang.NoSuchMethodException is actually pretty suspicious. The class ModuleReferenceImpl is an extended class of ModuleReference, which was available since Java 9.

maio290
  • 6,440
  • 1
  • 21
  • 38
  • 2
    But it’s strange to see that maven uses `getDeclaredMethod` on the implementation class, to access a method defined by the interface. It looks very much like the caller is aware that the interface does not exist in this version, whereas the class `ModuleReferenceImpl` obviously exists, as the JRE only complain about the method not being present in that class. – Holger Jan 17 '19 at 08:33