junit-team/junit5 · error · JUnitException

There should not be more than one ClasspathScanner implement

Error message

There should not be more than one ClasspathScanner implementation present on the classpath but there were %d: %s

What it means

Error "There should not be more than one ClasspathScanner implementation present on the classpath but there were %d: %s" thrown in junit-team/junit5.

Source

Thrown at junit-platform-commons/src/main/java/org/junit/platform/commons/util/ClasspathScannerLoader.java:36

import org.junit.platform.commons.support.scanning.ClasspathScanner;

/**
 * @since 1.12
 */
class ClasspathScannerLoader {

	static ClasspathScanner getInstance() {
		ServiceLoader<ClasspathScanner> serviceLoader = ServiceLoader.load(ClasspathScanner.class,
			ClassLoaderUtils.getDefaultClassLoader());

		List<Provider<ClasspathScanner>> classpathScanners = serviceLoader.stream().toList();

		if (classpathScanners.size() == 1) {
			return classpathScanners.get(0).get();
		}

		if (classpathScanners.size() > 1) {
			throw new JUnitException(
				"There should not be more than one ClasspathScanner implementation present on the classpath but there were %d: %s".formatted(
					classpathScanners.size(),
					classpathScanners.stream().map(Provider::type).map(Class::getName).toList()));
		}

		return new DefaultClasspathScanner(ClassLoaderUtils::getDefaultClassLoader, ReflectionUtils::tryToLoadClass);
	}

	private ClasspathScannerLoader() {
	}

}

View on GitHub (pinned to 956246301e)

When it happens

Trigger: Thrown at junit-platform-commons/src/main/java/org/junit/platform/commons/util/ClasspathScannerLoader.java:36 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of junit-team/junit5@956246301e (2026-08-04). Data as JSON: /data/errors/2bde776ef72d0d0b.json. Report an issue: GitHub.