Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassNotFoundException: CleanupMode #2991

Closed
1 task
t1 opened this issue Jul 28, 2022 · 4 comments
Closed
1 task

ClassNotFoundException: CleanupMode #2991

t1 opened this issue Jul 28, 2022 · 4 comments

Comments

@t1
Copy link
Contributor

t1 commented Jul 28, 2022

When updating from 5.8.2 to 5.9.0, I get the following stack trace:

Internal Error occurred.
org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests
	at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:160)
	at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverSafely(EngineDiscoveryOrchestrator.java:134)
	at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:108)
	at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:80)
	at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:110)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
	at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
	at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
	at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.lang.NoClassDefFoundError: org/junit/jupiter/api/io/CleanupMode
	at org.junit.jupiter.engine.JupiterTestEngine.discover(JupiterTestEngine.java:66)
	at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:152)
	... 13 more
Caused by: java.lang.ClassNotFoundException: org.junit.jupiter.api.io.CleanupMode
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	... 15 more

See t1/wunderbar#217

As the class is clearly there, I have no idea what's happening. Other projects can update without a problem.

Steps to reproduce

Just checkout the PR and run the tests in the wunderbar.junit module from IntelliJ. Maven fails, too, but the error message is not very helpful: TestEngine with ID 'junit-jupiter' failed to discover tests

Context

  • Used versions (Jupiter/Vintage/Platform): 5.9.0
  • Build Tool/IDE: Maven or IntelliJ IDEA

Deliverables

  • ...
@sbrannen
Copy link
Member

It might be because you depend on the BOM instead of importing it.

See https://github.com/junit-team/junit5-samples/blob/main/junit5-jupiter-starter-maven/pom.xml for an example of how to import the BOM and depend on junit-jupiter-api.

@aliaksei-astashenka
Copy link

Had the exact same issue today. For me it was the mess in project with spring boot dependencies and overriding some versions here and there in the project. The issue is that current Spring Boot still use 5.8.2 which doesn't have this new class org.junit.jupiter.api.io.CleanupMode.
So for me putting ext['junit-jupiter.version'] = <explicit 5.9.0 or variable from properties>solved the issue.

@sbrannen
Copy link
Member

Please note that the User Guide also documents how to upgrade the JUnit version used in a Spring Boot application.

@t1
Copy link
Contributor Author

t1 commented Jul 28, 2022

I didn't depend on the BOM but directly on junit-jupiter. After changing it to importing the BOM and then remove the version from the dependencies, it actually worked! Even though I'm using maven for about 20 years, now, I wasn't even aware that this could be an issue. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants