{"record":{"id":"b8111ad1633e73f9","repo":"apache/flink","slug":"jar-file-path-is-invalid","errorCode":null,"errorMessage":"JAR file path is invalid '{}'","messagePattern":"JAR file path is invalid '(.+?)'","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/util/JarUtils.java","lineNumber":43,"sourceCode":"import java.net.MalformedURLException;\nimport java.net.URISyntaxException;\nimport java.net.URL;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.jar.JarFile;\nimport java.util.stream.Collectors;\n\n/** Utility functions for jar files. */\n@Internal\npublic class JarUtils {\n\n    public static void checkJarFile(URL jar) throws IOException {\n        File jarFile;\n        try {\n            jarFile = new File(jar.toURI());\n        } catch (URISyntaxException e) {\n            throw new IOException(\"JAR file path is invalid '\" + jar + '\\'');\n        }\n        if (!jarFile.exists()) {\n            throw new IOException(\"JAR file does not exist '\" + jarFile.getAbsolutePath() + '\\'');\n        }\n        if (!jarFile.canRead()) {\n            throw new IOException(\"JAR file can't be read '\" + jarFile.getAbsolutePath() + '\\'');\n        }\n\n        try (JarFile ignored = new JarFile(jarFile)) {\n            // verify that we can open the Jar file\n        } catch (IOException e) {\n            throw new IOException(\n                    \"Error while opening jar file '\" + jarFile.getAbsolutePath() + '\\'', e);\n        }\n    }\n\n    public static List<URL> getJarFiles(final String[] jars) {\n        if (jars == null) {","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/util/JarUtils.java#L25-L61","documentation":"JarUtils.checkJarFile converts the given jar URL to a File via jar.toURI(). A URISyntaxException here means the URL is not a valid URI — it cannot even be converted to a filesystem path, so validation stops with this IOException naming the offending URL.","triggerScenarios":"Calling JarUtils.checkJarFile(url) with a URL whose URI form is syntactically invalid — e.g. a URL containing unencoded spaces, brackets, or a double slash produced by string concatenation instead of a proper URL/URI constructor.","commonSituations":"A jar path with spaces or special characters in directories like 'C:/Program Files/...' passed unencoded; building a jar URL by concatenating strings ('file:' + path) instead of File.toURI().toURL(); misconfigured pipeline.jars / -C classpath entries on the command line.","solutions":["Encode the path properly: build the URL with new File(path).toURI().toURL() instead of string concatenation.","Move or reference the jar from a path without spaces or special characters.","URL-encode problematic characters in the path (space -> %20) if the URL must be constructed manually.","Print the URL from the error message and validate it with new URI(url) to spot the syntax problem."],"exampleFix":"// before\nURL jarUrl = new URL(\"file:\" + jarPath); // breaks when jarPath has spaces\n\n// after\nURL jarUrl = new File(jarPath).toURI().toURL();","handlingStrategy":"validation","validationCode":"// Build the URL from a File so URI encoding is always valid\nURL jarUrl = new File(jarPath).getAbsoluteFile().toURI().toURL();\nJarUtils.checkJarFile(jarUrl);","typeGuard":null,"tryCatchPattern":"try {\n    JarUtils.checkJarFile(jar);\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"JAR file path is invalid\")) {\n        // re-encode the path via File.toURI().toURL() and retry once\n    }\n}","preventionTips":["Never concatenate 'file:' + path to build jar URLs","Avoid paths with spaces or URL-reserved characters for jars","Always construct jar URLs with File.toURI().toURL()"],"tags":["jar","url","classpath","configuration"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}