{"record":{"id":"9dd43f1ec6fa4d25","repo":"apache/flink","slug":"error-while-opening-jar-file","errorCode":null,"errorMessage":"Error while opening jar file '{}'","messagePattern":"Error while opening jar file '(.+?)'","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/util/JarUtils.java","lineNumber":55,"sourceCode":"\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) {\n            return Collections.emptyList();\n        }\n\n        return Arrays.stream(jars)\n                .map(\n                        jarPath -> {\n                            try {\n                                final URL fileURL =\n                                        new File(jarPath).getAbsoluteFile().toURI().toURL();\n                                JarUtils.checkJarFile(fileURL);\n                                return fileURL;\n                            } catch (MalformedURLException e) {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/util/JarUtils.java#L37-L73","documentation":"The final check in JarUtils.checkJarFile: the path is a valid URI, the file exists and is readable, but constructing java.util.jar.JarFile over it throws IOException. This means the file is not a valid zip/jar container (corrupt, truncated, or a different format) or the jar is invalid for the JVM's strictness settings.","triggerScenarios":"Calling JarUtils.checkJarFile on a file that exists and is readable but is not a well-formed jar: a partially downloaded jar, an HTML error page saved with a .jar extension, a zip64 jar rejected by the JVM, or a file corrupted in transfer.","commonSituations":"Interrupted download or truncated artifact from a repository mirror; a proxy served an HTML 403 page saved as the jar name; jars corrupted by git LFS pointer files not being pulled; FTP/SCP transfer in ASCII mode mangling binary bytes.","solutions":["Inspect the cause exception (zip error details) and verify the file: run 'jar tf file.jar' or 'unzip -t file.jar' to confirm it is a valid archive.","Re-download or re-transfer the jar in binary mode from a trusted source and verify its checksum (sha512sum).","If git LFS is used, run 'git lfs pull' so pointer placeholders become real binaries.","Regenerate the jar from a clean build if it was produced by a failed/partial packaging step."],"exampleFix":"# before\n$ jar tf connector.jar\njava.util.zip.ZipException: zip END header not found\n\n# after (re-download and verify)\n$ curl -O https://repo.example/connector.jar\n$ sha512sum -c connector.jar.sha512\n$ jar tf connector.jar   # lists entries OK","handlingStrategy":"validation","validationCode":"// Cheap integrity probe before checkJarFile\ntry (java.util.jar.JarFile probe = new java.util.jar.JarFile(new File(jarUrl.toURI()))) {\n    probe.stream().findFirst(); // forces central-directory parse\n}\nJarUtils.checkJarFile(jarUrl);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify jar checksums (sha512) after download","Use binary-mode transfers and git lfs pull for binary artifacts","Run 'unzip -t' on jars fetched from mirrors before deploying"],"tags":["jar","corruption","zip","classpath","download"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}