Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-1605

NoClassDefFoundError (RunNotifier) with JDK 11

    Details

      Description

      I have a JUnit 4 test.  JUnit 4.12 is on the test classpath.  I'm using JDK 11 via toolchains and the Surefire plugin version 3.0.0-M1.

      mvn test fails with the following dump indicating that JDK 11's jdk.internal.loader.BuiltinClassLoader cannot find the JUnit 4 class org.junit.runner.notification.RunNotifier class:

      # Created at 2018-11-30T14:30:40.517
      java.lang.NoClassDefFoundError: org/junit/runner/notification/RunNotifier
      at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
      at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3138)
      at java.base/java.lang.Class.getConstructor0(Class.java:3343)
      at java.base/java.lang.Class.getConstructor(Class.java:2152)
      at org.apache.maven.surefire.util.ReflectionUtils.getConstructor(ReflectionUtils.java:83)
      at org.apache.maven.surefire.util.ReflectionUtils.instantiateOneArg(ReflectionUtils.java:122)
      at org.apache.maven.surefire.booter.ForkedBooter.createProviderInCurrentClassloader(ForkedBooter.java:403)
      at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:383)
      at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
      at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
      Caused by: java.lang.ClassNotFoundException: org.junit.runner.notification.RunNotifier
      at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
      at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
      at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
      ... 11 more

      I see no workaround.

      The contents of the arguments file are:

      --module-path
      /Users/LANELSON/Projects/github/microbean/ristretto/microbean-ristretto-bean/target/classes:/Users/LANELSON/.m2/repository/org/microbean/microbean-ristretto-context/0.0.1-SNAPSHOT/microbean-ristretto-context-0.0.1-SNAPSHOT.jar:/Users/LANELSON/.m2/repository/org/microbean/microbean-ristretto-javax-enterprise-context/0.0.1-SNAPSHOT/microbean-ristretto-javax-enterprise-context-0.0.1-SNAPSHOT.jar:/Users/LANELSON/.m2/repository/org/microbean/microbean-ristretto-javax-enterprise-context-spi/0.0.1-SNAPSHOT/microbean-ristretto-javax-enterprise-context-spi-0.0.1-SNAPSHOT.jar:/Users/LANELSON/.m2/repository/org/microbean/microbean-ristretto-javax-enterprise-inject-spi/0.0.1-SNAPSHOT/microbean-ristretto-javax-enterprise-inject-spi-0.0.1-SNAPSHOT.jar:/Users/LANELSON/.m2/repository/org/microbean/microbean-ristretto-javax-el/0.0.1-SNAPSHOT/microbean-ristretto-javax-el-0.0.1-SNAPSHOT.jar:/Users/LANELSON/.m2/repository/org/microbean/microbean-ristretto-javax-enterprise-event/0.0.1-SNAPSHOT/microbean-ristretto-javax-enterprise-event-0.0.1-SNAPSHOT.jar:/Users/LANELSON/.m2/repository/org/microbean/microbean-ristretto-javax-enterprise-inject/0.0.1-SNAPSHOT/microbean-ristretto-javax-enterprise-inject-0.0.1-SNAPSHOT.jar:/Users/LANELSON/.m2/repository/org/microbean/microbean-ristretto-javax-enterprise-util/0.0.1-SNAPSHOT/microbean-ristretto-javax-enterprise-util-0.0.1-SNAPSHOT.jar:/Users/LANELSON/.m2/repository/org/microbean/microbean-ristretto-javax-inject/0.0.1-SNAPSHOT/microbean-ristretto-javax-inject-0.0.1-SNAPSHOT.jar:/Users/LANELSON/.m2/repository/org/microbean/microbean-ristretto-javax-interceptor/0.0.1-SNAPSHOT/microbean-ristretto-javax-interceptor-0.0.1-SNAPSHOT.jar:/Users/LANELSON/.m2/repository/org/microbean/microbean-development-annotations/0.2.2/microbean-development-annotations-0.2.2.jar:/Users/LANELSON/.m2/repository/com/fasterxml/classmate/1.4.0/classmate-1.4.0.jar
      --class-path
      /Users/LANELSON/.m2/repository/org/apache/maven/surefire/surefire-booter/3.0.0-M1/surefire-booter-3.0.0-M1.jar:/Users/LANELSON/.m2/repository/org/apache/maven/surefire/surefire-api/3.0.0-M1/surefire-api-3.0.0-M1.jar:/Users/LANELSON/.m2/repository/org/apache/maven/surefire/surefire-logger-api/3.0.0-M1/surefire-logger-api-3.0.0-M1.jar:/Users/LANELSON/.m2/repository/org/apache/maven/surefire/surefire-junit4/3.0.0-M1/surefire-junit4-3.0.0-M1.jar:/Users/LANELSON/.m2/repository/org/apache/maven/surefire/common-java5/3.0.0-M1/common-java5-3.0.0-M1.jar:/Users/LANELSON/.m2/repository/org/apache/maven/surefire/common-junit3/3.0.0-M1/common-junit3-3.0.0-M1.jar:/Users/LANELSON/.m2/repository/org/apache/maven/surefire/common-junit4/3.0.0-M1/common-junit4-3.0.0-M1.jar:/Users/LANELSON/.m2/repository/org/apache/maven/shared/maven-shared-utils/3.1.0/maven-shared-utils-3.1.0.jar
      --patch-module
      org.microbean.ristretto.bean=/Users/LANELSON/Projects/github/microbean/ristretto/microbean-ristretto-bean/target/test-classes
      --add-exports
      org.microbean.ristretto.bean/org.microbean.ristretto.bean=ALL-UNNAMED
      --add-exports
      org.microbean.ristretto.bean/org.microbean.ristretto.type=ALL-UNNAMED
      --add-modules
      org.microbean.ristretto.bean
      --add-reads
      org.microbean.ristretto.bean=ALL-UNNAMED
      org.apache.maven.surefire.booter.ForkedBooter
      

      I don't see junit.jar on the classpath.

      mvn dependency:tree includes the following:

      [INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) @ microbean-ristretto-bean ---
      [various things]
      [INFO] \- junit:junit:jar:4.12:test
      [INFO]    \- org.hamcrest:hamcrest-core:jar:1.3:test
      

        Attachments

          Activity

            People

            • Assignee:
              tibordigana Tibor Digana
              Reporter:
              ljnelson Laird Nelson
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: