-1

I've got the following issue while I've been trying to use latest version of the JUnit5 (5.10.3) and latest version of the maven-surefire-plugin (3.3.0).

Caused by: org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
org/apache/maven/surefire/report/RunModeSetter
java.lang.NoClassDefFoundError: org/apache/maven/surefire/report/RunModeSetter
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:113)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
    at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
    at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
Caused by: java.lang.ClassNotFoundException: org.apache.maven.surefire.report.RunModeSetter
    at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        ... 17 more

I've followed most of the official instructions (both junit and maven surefire) but nothing seems helping in my case.

The only difference is that the issue disappear if I go back to maven-surefire-plugin with version 3.0.0-M3

Are there any ways to found is it something known and already in-fix or what would be done differently on my end? It is a bit confusing that according to the maven surefire documentation everything should work.

p.s. I'm using JUnit5 as a bom and tried different combination of corresponding dependencies, like both engine and api or just api p.p.s. As for the maven version:

$ mvn -version
Apache Maven 3.9.0 (9b58d2bad23a66be161c4664ef21ce219c2c8584)
Maven home: C:\Users\mlaptev\Downloads\apache-maven-3.9.0
Java version: 1.8.0_412, vendor: Temurin, runtime: C:\Program Files\Eclipse Adoptium\jdk-8.0.412.8-hotspot\jre
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

3
  • edit the question and add a minimal reproducible example. Include version of Maven and the pom.xml.
    – aled
    Commented Jul 9 at 14:18
  • Please post your pom file...
    – khmarbaise
    Commented Jul 9 at 15:02
  • that's something that I'm trying to extract, since due to obvious reasons, I cannot post the pom.xml as is
    – mnlaptev
    Commented Jul 9 at 15:44

2 Answers 2

0

Try updating your jdk to 17 or any latest version

1
  • That is not related...
    – khmarbaise
    Commented Jul 9 at 15:02
0

1. Update below POM Configuration in the "pom.xml"

    <dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.10.3</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.10.3</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.3.0</version>
            <configuration>
                <useModulePath>false</useModulePath>
            </configuration>
        </plugin>
    </plugins>
</build>

2. then force update dependencies by using

mvn clean install -U
1
  • that didn't help unfortunately. it is probably something messy in the setup we are having, continue to look into it. but, meanwhile, when with everything working on 3.0.0-M3, switching to 3.0.0-M4 lead to issue that is similar to issues.apache.org/jira/browse/SUREFIRE-1951 and after adding workaround as it has been mentioned in the jira, the originally posted issue has happen after switching from 3.0.0-M5 to 3.0.0-M6. will continue looking into the smallest project that can be used as reproducer
    – mnlaptev
    Commented Jul 9 at 16:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.