{"record":{"id":"f9e1b1321470dca0","repo":"junit-team/junit5","slug":"invalid-classpath-entry-path","errorCode":null,"errorMessage":"Invalid classpath entry: ${path}","messagePattern":"Invalid classpath entry: (.+?)","errorType":"exception","errorClass":"JUnitException","httpStatus":null,"severity":"error","filePath":"junit-platform-console/src/main/java/org/junit/platform/console/command/ConsoleTestExecutor.java","lineNumber":183,"sourceCode":"\t\tlauncher.execute(executionRequest);\n\t}\n\n\tprivate @Nullable CustomClassLoader createCustomClassLoader() {\n\t\tList<Path> additionalClasspathEntries = discoveryOptions.getExistingAdditionalClasspathEntries();\n\t\tif (!additionalClasspathEntries.isEmpty()) {\n\t\t\tURL[] urls = additionalClasspathEntries.stream().map(this::toURL).toArray(URL[]::new);\n\t\t\tClassLoader parentClassLoader = ClassLoaderUtils.getDefaultClassLoader();\n\t\t\treturn new CustomClassLoader(URLClassLoader.newInstance(urls, parentClassLoader));\n\t\t}\n\t\treturn null;\n\t}\n\n\tprivate URL toURL(Path path) {\n\t\ttry {\n\t\t\treturn path.toUri().toURL();\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tthrow new JUnitException(\"Invalid classpath entry: \" + path, ex);\n\t\t}\n\t}\n\n\tprivate SummaryGeneratingListener registerListeners(PrintWriter out, Optional<Path> reportsDir, Launcher launcher,\n\t\t\t@Nullable CancellationToken cancellationToken) {\n\n\t\t// always register summary generating listener\n\t\tSummaryGeneratingListener summaryListener = new SummaryGeneratingListener();\n\t\tlauncher.registerTestExecutionListeners(summaryListener);\n\t\t// optionally, register test plan execution details printing listener\n\t\tcreateDetailsPrintingListener(out).ifPresent(launcher::registerTestExecutionListeners);\n\t\t// optionally, register XML reports writing listener\n\t\tcreateXmlWritingListener(out, reportsDir).ifPresent(launcher::registerTestExecutionListeners);\n\t\tcreateFailFastListener(cancellationToken).ifPresent(launcher::registerTestExecutionListeners);\n\t\treturn summaryListener;\n\t}\n\n\tprivate Optional<DetailsPrintingListener> createDetailsPrintingListener(PrintWriter out) {","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/junit-team/junit5/blob/f070c699a08b5d8393df9afd147af5c5e90bb21b/junit-platform-console/src/main/java/org/junit/platform/console/command/ConsoleTestExecutor.java#L165-L201","documentation":"ConsoleTestExecutor.toURL() converts a user-supplied --additional-classpath-entry path into a URL for a custom URLClassLoader. If the Path cannot be turned into a URI/URL (typically an IOException or malformed input), a JUnitException wraps the cause. It signals the entry supplied on the command line cannot be used as a classpath root.","triggerScenarios":"Passing --additional-classpath-entry with a path that does not exist or whose Path.toUri().toURL() throws — e.g. a path on a non-default FileSystem (a Path inside a zip/jar via a custom provider), a path with characters the URI parser rejects, or a path whose provider does not support URL conversion.","commonSituations":"Pointing --additional-classpath-entry at a non-existent file, a directory inside a custom FileSystem (e.g. a Path obtained from an opened jar FileSystem), or a path with unencoded special characters. Also seen when the supplied string resolves against an unusual default FileSystem.","solutions":["Verify the path exists and is on the default/platform FileSystem: Files.exists(path) && path.getFileSystem() == FileSystems.getDefault().","Convert the entry to a real file on disk (extract or copy) and reference that absolute path.","If the path is valid but special-character-laden, URL-encode the path or use the file:// URI form directly if supported by the surrounding setup.","Prefer putting the jar/directory on the real -cp / CLASSPATH instead of --additional-classpath-entry when in doubt."],"exampleFix":"// before\njava -jar junit-platform-console-standalone.jar execute --additional-classpath-entry /opt/missing/lib.jar\n// after: ensure the path exists and is a real file\nls /opt/missing/lib.jar  # fix path\njava -jar junit-platform-console-standalone.jar execute --additional-classpath-entry /opt/real/lib.jar","handlingStrategy":"validation","validationCode":"// Validate the path before passing it as an additional classpath entry.\nimport java.nio.file.*;\nPath p = Paths.get(userEntry);\nif (!Files.exists(p))      throw new IllegalArgumentException(\"classpath entry does not exist: \" + userEntry);\nif (!Files.isReadable(p))  throw new IllegalArgumentException(\"classpath entry not readable: \" + userEntry);\nif (p.getFileSystem() != FileSystems.getDefault())\n  throw new IllegalArgumentException(\"classpath entry is not on the default filesystem: \" + userEntry);\n// If ok, pass --additional-classpath-entry userEntry\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always reference additional classpath entries by absolute paths on local disk.","Confirm entries exist and are readable before running the launcher.","Prefer the standard -cp / CLASSPATH over --additional-classpath-entry when possible."],"tags":["classpath","console-launcher","filesystem","url"],"backgroundTag":null,"analyzedSha":"f070c699a08b5d8393df9afd147af5c5e90bb21b","analyzedAt":"2026-08-11T20:31:00.530Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}