maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Scholte (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SUREFIRE-1605) NoClassDefFoundError (RunNotifier) with JDK 11
Date Sat, 01 Dec 2018 22:19:00 GMT

    [ https://issues.apache.org/jira/browse/SUREFIRE-1605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16706025#comment-16706025
] 

Robert Scholte commented on SUREFIRE-1605:
------------------------------------------

[~tibor17] I've adjusted {{org.apache.maven.plugin.surefire.AbstractSurefireMojo.newStartupConfigWithModularPath()}}
a little bit by adding the following code"

{code}
        for ( Entry<String, Exception> entry : result.getPathExceptions().entrySet()
)
        {
            getConsoleLogger().warning( "Exception for " + entry.getKey(), entry.getValue()
);
        }
{code}

This will show the following error: java.lang.UnsupportedOperationException for hamcrest and
junit.
Plexus-Java is trying to resolve this with the targeted JDK when provided. It is not provided,
so it tries to use JDK8, hence the UnsupportedOperationException.
The first versions were using ASM, but that means updating every 6 month. Instead I switch
to Java 9 implementation, which should be there anyway to compile/run.
The fix: call {{ResolvePathsRequest.setJdkHome()}} with the path of the toolchains jdk path.



> NoClassDefFoundError (RunNotifier) with JDK 11
> ----------------------------------------------
>
>                 Key: SUREFIRE-1605
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1605
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: Junit 4.x support, Maven Surefire Plugin
>    Affects Versions: 3.0.0-M1
>            Reporter: Laird Nelson
>            Priority: Major
>
> 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:
> {code:java}
> # 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{code}
> I see no workaround.
> The contents of the arguments file are:
> {code:java}
> --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
> {code}
> I don't see {{junit.jar}} on the classpath.
> {{mvn dependency:tree}} includes the following:
> {code}
> [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
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message