Spring Boot fails to run maven-surefire-plugin ClassNotFoundException org.apache.maven.surefire.booter.ForkedBooter
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Spring Boot is widely used in the Java ecosystem for building microservices and standalone applications. However, like any other technology stack, it can run into configuration issues. One such issue is when applications using Spring Boot fail to run tests because of a ClassNotFoundException
related to org.apache.maven.surefire.booter.ForkedBooter
when using the maven-surefire-plugin
. Let's delve into the technicalities of why this exception might occur and how you can solve it.
Understanding the Problem
The maven-surefire-plugin
is a Maven plugin primarily used for running tests in a Maven project. It forks a new process to run test cases to ensure that the test JVM is cleanly isolated from the build environment. This process is coordinated by a class called ForkedBooter
.
When Maven fails to find the ForkedBooter
, it throws a ClassNotFoundException
. This may happen for several reasons:
- Dependency Conflicts: The classpath might be improperly configured, resulting in missing dependencies during test execution.
- Plugin Version: Using an incompatible or older version of
maven-surefire-plugincould cause this issue. The plugin's version might not be compatible with your JDK or other dependencies. - Corrupted Local Repository: If your Maven local repository is corrupted, Maven may be unable to fetch the required dependencies.
- Project Configuration: Misconfiguration in the
pom.xmlcan also disrupt Maven's ability to build and run your tests correctly.
Technical Explanations and Solutions
Checking Dependency Conflicts
To diagnose classpath issues, it's effective to first ensure that there are no version conflicts with your dependencies:
- Run Maven with the dependency tree goal:
- Look for dependency convergence errors or conflicts. You can resolve these by using appropriate versions in your
pom.xml: - Open your
pom.xml. - Navigate to the
buildsection and find theplugins: - Update the plugin version to one that matches your system's JDK.
- Delete the problematic directories in your local repository (
~/.m2/repository). - Use the
-Uflag to force update dependencies: - Check for the presence of any custom configurations that might lead to conflicts.
- Verify the scope of dependencies, especially those required during the test phase.
Related reading
- Spring Boot Getting Scheduled cron value from database
- Spring Boot gives TemplateInputException Error resolving template when running from jar
- Spring Boot Gradle how to build executable jar
- Spring Boot /h2-console throws 403 with Spring Security 1.5.2
- Spring Boot Handler dispatch failed; nested exception is java.lang.NoSuchMethodError
- Spring boot hikari - dataSource or dataSourceClassName or jdbcUrl is required issue
- Spring Boot Hibernate and Flyway boot order
- Spring Boot hotswap with IntelliJ IDE

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.