Explain Codes LogoExplain Codes Logo

Maven surefire could not find ForkedBooter class

java
maven
surefire
plugin-issues
Alex KataevbyAlex Kataev·Dec 31, 2024
TLDR

To swiftly vanquish the ForkedBooter class not found error, your pathway to victory involves an upgrade of Surefire plugin and a Maven cache cleansing. Time to roll up your sleeves!

  1. Upgrade Surefire: Up the ante on the Surefire plugin version within your pom.xml.
<!-- This ain't no place for outdated plugins! --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>Brace-Yourself-With-Latest-Version</version> </plugin>
  1. Purge the Cache: Bust out that broom and clean the potentially corrupt or outdated Surefire cache from your .m2 directory.
# Time for a clean slate, cache. No hard feelings! rm -rf ~/.m2/repository/org/apache/maven/plugins/maven-surefire-plugin
  1. Reconstruct: Unravel the magic of mvn clean install to recompile and summon the freshest dependencies.

A quick gambol through these steps should checkmate the issue.

Lock and load with advanced strategies

System upgrades

To fortify your project, ensure your Java Development Kit (JDK) is up-to-date, specifically at version 8u191-b12 or later. This offers crucial security and performance enhancements and ticks off a good practice box!

Debugging Plugin Issues

A spooky bug can come out of nowhere! The one terrorizing your Surefire plugin is tracked under Apache's JIRA: SUREFIRE-1588. It's responsible for the disappearance act of the ForkedBooter class from its usual classpath territory. Sniper it with the Surefire plugin version 3.0.0-M1 or later.

The Temporary Shield: Workaround

In times of crisis, a temporary bypass can be triggered by rolling out a JVM property -Djdk.net.URLClassPath.disableClassPathURLCheck=true. It bypasses certain classpath checks impeding the location of the ForkedBooter Class.

Maven profiles for the win!

Your settings.xml config can be maneuvered to summon a profile for the Surefire plugin inclusive of -Djdk.net.URLClassPath.disableClassPathURLCheck=true property. This resilient stronghold ensures each build is safe from errors.

<!-- Trust me! I got your back. --> <profile> <id>SUREFIRE-1588-workaround</id> <properties> <argLine>-Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine> </properties> </profile>

Bring out the big guns: Fix deployment

The fix is here, and it's raring to go! Be proactive and ensure your Maven configuration is all buttoned up with the fixed packages. Stamp your version of Surefire plugin in pom.xml to 3.0.0-M1 or later. Unleash a successful build without the ForkedBooter class error meddling in the picture.

Venturing into company proxy territory with Maven may feel like threading on eggshells. Slate a <proxy> configuration within your settings.xml to ensure Maven's smooth communication with external repositories to acquire necessary assets, like the Surefire plugin.

Environmentally Savvy Moves

Flex the power of the _JAVA_OPTIONS environment variable to embed the URLClassPath check workaround. This guarantees a reliable setup, irrespective of your Maven invocation style:

# Because who doesn't love universality! export _JAVA_OPTIONS="-Djdk.net.URLClassPath.disableClassPathURLCheck=true"

This brings out a universally applicable setting with no revamps needed in Maven configurations or build scripts, giving you more time for coffee breaks! ☕

Resolving Test Failures as a Pro

Post Surefire upgrade, you might encounter test failures; consider them as bonus levels! Conquer them with a thorough test audit to identify and neutralize any hidden issues, fortifying your build further.