quarkusio/quarkus · error · UncheckedIOException

Failed to read <jar>

Error message

Failed to read <jar>

What it means

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).

Source

Thrown at independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/descriptor/loader/json/ResourceLoaders.java:69

    // This method is copied from io.quarkus.runtime.util.ClassPathUtils
    public static <R> R processAsPath(URL url, Function<Path, R> function) {
        if (JAR.equals(url.getProtocol())) {
            final String file = url.getFile();
            final int exclam = file.lastIndexOf('!');
            final Path jar;
            try {
                jar = toLocalPath(exclam >= 0 ? new URL(file.substring(0, exclam)) : url);
            } catch (MalformedURLException e) {
                throw new RuntimeException("Failed to create a URL for '" + file.substring(0, exclam) + "'", e);
            }
            try (FileSystem jarFs = ZipUtils.newFileSystem(jar)) {
                Path localPath = jarFs.getPath("/");
                if (exclam >= 0) {
                    localPath = localPath.resolve(file.substring(exclam + 1));
                }
                return function.apply(localPath);
            } catch (IOException e) {
                throw new UncheckedIOException("Failed to read " + jar, e);
            }
        }

        if (FILE.equals(url.getProtocol())) {
            return function.apply(toLocalPath(url));
        }

        throw new IllegalArgumentException("Unexpected protocol " + url.getProtocol() + " for URL " + url);
    }

    private static Path toLocalPath(final URL url) {
        try {
            return Paths.get(url.toURI());
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException("Failed to translate " + url + " to local path", e);
        }
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Verify the JAR file at the path in the message exists and is a valid zip (try `unzip -t <jar>`)
  2. Delete the corrupt artifact from the local Maven repository (~/.m2/repository) and re-resolve/rebuild so it is re-downloaded
  3. Check disk space and file permissions on the JAR

Example fix

// shell
rm -rf ~/.m2/repository/io/quarkus/platform/quarkus-bom/2.16.0
mvn -U dependency:resolve
Defensive patterns

Strategy: try-catch

Validate before calling

static boolean isReadableZip(Path p) {
    if (p == null || !Files.isRegularFile(p)) return false;
    try (ZipFile zf = new ZipFile(p.toFile())) { return zf.size() >= 0; }
    catch (IOException e) { return false; }
}

Try / catch

try {
    ResourceLoaders.processAsPath(url, fn);
} catch (UncheckedIOException e) {
    log.error("JAR unreadable: " + e.getMessage() + ". Delete it and re-resolve.", e);
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/ca98cd8a4493ac5f. Report an issue: GitHub.