{"record":{"id":"ca98cd8a4493ac5f","repo":"quarkusio/quarkus","slug":"failed-to-read-jar","errorCode":null,"errorMessage":"Failed to read <jar>","messagePattern":"Failed to read <jar>","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/descriptor/loader/json/ResourceLoaders.java","lineNumber":69,"sourceCode":"    // This method is copied from io.quarkus.runtime.util.ClassPathUtils\n    public static <R> R processAsPath(URL url, Function<Path, R> function) {\n        if (JAR.equals(url.getProtocol())) {\n            final String file = url.getFile();\n            final int exclam = file.lastIndexOf('!');\n            final Path jar;\n            try {\n                jar = toLocalPath(exclam >= 0 ? new URL(file.substring(0, exclam)) : url);\n            } catch (MalformedURLException e) {\n                throw new RuntimeException(\"Failed to create a URL for '\" + file.substring(0, exclam) + \"'\", e);\n            }\n            try (FileSystem jarFs = ZipUtils.newFileSystem(jar)) {\n                Path localPath = jarFs.getPath(\"/\");\n                if (exclam >= 0) {\n                    localPath = localPath.resolve(file.substring(exclam + 1));\n                }\n                return function.apply(localPath);\n            } catch (IOException e) {\n                throw new UncheckedIOException(\"Failed to read \" + jar, e);\n            }\n        }\n\n        if (FILE.equals(url.getProtocol())) {\n            return function.apply(toLocalPath(url));\n        }\n\n        throw new IllegalArgumentException(\"Unexpected protocol \" + url.getProtocol() + \" for URL \" + url);\n    }\n\n    private static Path toLocalPath(final URL url) {\n        try {\n            return Paths.get(url.toURI());\n        } catch (URISyntaxException e) {\n            throw new IllegalArgumentException(\"Failed to translate \" + url + \" to local path\", e);\n        }\n    }\n}","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/descriptor/loader/json/ResourceLoaders.java#L51-L87","documentation":"When the resource URL refers to a location inside a JAR, processAsPath opens the JAR as a Zip FileSystem and applies the consumer to the resolved path. If opening or reading the JAR filesystem raises IOException, it is rethrown as UncheckedIOException(\"Failed to read \" + jar).","triggerScenarios":"ZipUtils.newFileSystem(jar) or reading entries from the zip filesystem fails: the JAR file does not exist at the resolved path, is corrupt/truncated, or has unsupported zip format.","commonSituations":"Partially downloaded or interrupted Maven artifact; JAR deleted between URL resolution and read; damaged JAR in local repository after a crashed build; wrong path resolved from a non-file URL.","solutions":["Verify the JAR file at the path in the message exists and is a valid zip (try `unzip -t <jar>`)","Delete the corrupt artifact from the local Maven repository (~/.m2/repository) and re-resolve/rebuild so it is re-downloaded","Check disk space and file permissions on the JAR"],"exampleFix":"// shell\nrm -rf ~/.m2/repository/io/quarkus/platform/quarkus-bom/2.16.0\nmvn -U dependency:resolve","handlingStrategy":"try-catch","validationCode":"static boolean isReadableZip(Path p) {\n    if (p == null || !Files.isRegularFile(p)) return false;\n    try (ZipFile zf = new ZipFile(p.toFile())) { return zf.size() >= 0; }\n    catch (IOException e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n    ResourceLoaders.processAsPath(url, fn);\n} catch (UncheckedIOException e) {\n    log.error(\"JAR unreadable: \" + e.getMessage() + \". Delete it and re-resolve.\", e);\n    throw e;\n}","preventionTips":["Use `unzip -t` or Maven's dependency:purge-local-repository when builds fail on artifact reads","Never share a local Maven repository across concurrent builds without -Dmaven.repo.local isolation","Monitor disk space on build machines to avoid truncated downloads"],"tags":["io","jar","zip","corrupt-file"],"backgroundTag":"corrupt-or-missing-jar","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}