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

Could not find or load main class org.apache.maven.surefire.booter.ForkedBooter #717

Closed
shanmukhateja opened this issue Dec 8, 2018 · 5 comments

Comments

@shanmukhateja
Copy link

Background:
I'm a first timer trying to resolve the issue #702 and I have been following the CONTRIBUTING.md file. I cloned the project, installed maven (sudo apt install maven) and then ran mvn test as per the CONTRIBUTING.md
I got the following error:
Error: Could not find or load main class org.apache.maven.surefire.booter.ForkedBooter

I then tried using mvnw test file on ~/oshi/ directory but still got the same error.

However, with a quick Google search, I ended up here which said to add the following line to pom.xml:
<useSystemClassLoader>false</useSystemClassLoader>

I am now finally able to run tests. I am creating this issue so that newcomers like me wouldn't have to go through this again.

OS: Debian Stretch x64
Maven version 3.3.9
Java: openjdk version "1.8.0_181"

@BilalAM
Copy link
Contributor

BilalAM commented Dec 8, 2018

I heard of this exception , this was a valid bug and the solution is to upgrade your jdk , also if that still persists then update your maven version . If the problem still persists then look at your environment variables , usually stuff like this happens due to this .

@dbwiddis
Copy link
Member

dbwiddis commented Dec 8, 2018

While the line you posted is the accepted answer, the answer below that indicates that can break some other Spring Boot integration and they (and other internet sources) recommend this instead:
<argLine>-Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>

Alternately we can just require version 3.0.0-M1 of the plugin.

@shanmukhateja
Copy link
Author

Good to know.

the solution is to upgrade your jdk

@BilalAM do you mean use JDK 11?

@dbwiddis
Copy link
Member

dbwiddis commented Dec 9, 2018

Browsing the upstream issue, Oracle Java 1.8.0_191 is mentioned. Not sure if that is the point that causes the issue or fixes it, though...

Given the bug is fixed in 3.0.0-M1 I think this may be the best solution.

@dbwiddis dbwiddis changed the title mvn test fails everytime Could not find or load main class org.apache.maven.surefire.booter.ForkedBooter Dec 11, 2018
@dbwiddis
Copy link
Member

Looking in detail at the upstream issue:

  • The issue appears to have been introduced in Oracle and OpenJDK 1.8.0_181 when backporting some Java 10 features (and claimed as a security feature, not a bug).
  • It only appears to affect Debian-based Linux distros.
  • Downgrading to an earlier Java version removes the stricter check causing the issue. Upgrading to 1.8.0_191 (on Debian distros) also appears to resolve this with default settings which disable the check, at least temporarily.
  • The Maven surefire plugin fixed this in 3.0.0-M1 and has no intention on fixing the 2.x branch past 2.22.1.

Fixes:

  • Do nothing (yet) Have anyone affected by this issue (Debian users) update their JVM.
  • Do nothing (yet) but if you want to build, add -DskipTests for the build and then run mvn test separately later.
  • Set useSystemClassLoader = false in the pom. This is a workaround and may be an appropriate temporary step until we upgrade the plugin version, but I'm leaning away from it.
  • Set forkCount to 0 in the surefire plugin. This could make slower builds.
  • Upgrade the surefire plugin to 3.0.0-M1. Not sure why we can't just do this now, and I think this is the best option from a project standpoint, rather than playing with workarounds.

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

No branches or pull requests

3 participants