{"id":"2bde776ef72d0d0b","repo":"junit-team/junit5","slug":"there-should-not-be-more-than-one-classpathscanner","errorCode":null,"errorMessage":"There should not be more than one ClasspathScanner implementation present on the classpath but there were %d: %s","messagePattern":"There should not be more than one ClasspathScanner implementation present on the classpath but there were (.+?): (.+?)","errorType":"exception","errorClass":"JUnitException","httpStatus":null,"severity":"error","filePath":"junit-platform-commons/src/main/java/org/junit/platform/commons/util/ClasspathScannerLoader.java","lineNumber":36,"sourceCode":"import org.junit.platform.commons.support.scanning.ClasspathScanner;\n\n/**\n * @since 1.12\n */\nclass ClasspathScannerLoader {\n\n\tstatic ClasspathScanner getInstance() {\n\t\tServiceLoader<ClasspathScanner> serviceLoader = ServiceLoader.load(ClasspathScanner.class,\n\t\t\tClassLoaderUtils.getDefaultClassLoader());\n\n\t\tList<Provider<ClasspathScanner>> classpathScanners = serviceLoader.stream().toList();\n\n\t\tif (classpathScanners.size() == 1) {\n\t\t\treturn classpathScanners.get(0).get();\n\t\t}\n\n\t\tif (classpathScanners.size() > 1) {\n\t\t\tthrow new JUnitException(\n\t\t\t\t\"There should not be more than one ClasspathScanner implementation present on the classpath but there were %d: %s\".formatted(\n\t\t\t\t\tclasspathScanners.size(),\n\t\t\t\t\tclasspathScanners.stream().map(Provider::type).map(Class::getName).toList()));\n\t\t}\n\n\t\treturn new DefaultClasspathScanner(ClassLoaderUtils::getDefaultClassLoader, ReflectionUtils::tryToLoadClass);\n\t}\n\n\tprivate ClasspathScannerLoader() {\n\t}\n\n}\n","sourceCodeStart":18,"sourceCodeEnd":49,"githubUrl":"https://github.com/junit-team/junit5/blob/956246301e03d757539f7b76dd5a91f298637563/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ClasspathScannerLoader.java#L18-L49","documentation":"Error \"There should not be more than one ClasspathScanner implementation present on the classpath but there were %d: %s\" thrown in junit-team/junit5.","triggerScenarios":"Thrown at junit-platform-commons/src/main/java/org/junit/platform/commons/util/ClasspathScannerLoader.java:36 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"956246301e03d757539f7b76dd5a91f298637563","analyzedAt":"2026-08-04T19:25:17.049Z","schemaVersion":2}