quarkusio/quarkus · error · RuntimeException

Failed to read zip entry ${res}

Error message

Failed to read zip entry ${res}

What it means

Wraps an IOException thrown while opening or reading a jar entry's stream in getResourceData — the zip entry could not be read at all (unlike 3146, which is a short read). Typically a corrupt zip structure, CRC error, or the jar file becoming unreadable mid-read.

Source

Thrown at independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/JarResource.java:91

            ZipEntry entry = jarFile.getEntry(res);
            if (entry == null) {
                return null;
            }
            try (InputStream is = jarFile.getInputStream(entry)) {
                byte[] data = new byte[(int) entry.getSize()];
                int pos = 0;
                int rem = data.length;
                while (rem > 0) {
                    int read = is.read(data, pos, rem);
                    if (read == -1) {
                        throw new RuntimeException("Failed to read all data for " + res);
                    }
                    pos += read;
                    rem -= read;
                }
                return data;
            } catch (IOException e) {
                throw new RuntimeException("Failed to read zip entry " + res, e);
            }
        }
    }

    @Override
    public URL getResourceURL(String resource) {
        return JarFileReference.withJarFile(this, resource, JarResourceURLProvider.INSTANCE);
    }

    private static class JarResourceURLProvider implements JarFileReference.JarFileConsumer<URL> {
        private static final JarResourceURLProvider INSTANCE = new JarResourceURLProvider();

        @Override
        public URL apply(JarFile jarFile, Path path, String resource) {
            JarEntry entry = jarFile.getJarEntry(resource);
            if (entry == null) {
                return null;
            }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Run unzip -t on the jar to confirm corruption and rebuild/redeploy it.
  2. Restart the application after a clean redeploy so the classloader reopens valid jars.
  3. Check host disk health and free space; review dmesg/filesystem logs for IO errors.
  4. Ensure deploys use atomic replacement (copy to temp + rename) rather than in-place overwrite.

Example fix

// before
cp new.jar /deploy/lib/app.jar  # while app runs
// after
cp new.jar /deploy/lib/.app.jar.tmp && mv /deploy/lib/.app.jar.tmp /deploy/lib/app.jar  # restart app after
Defensive patterns

Strategy: try-catch

Validate before calling

try (var zf = new java.util.zip.ZipFile(jar.toFile())) { var e = zf.entries(); while (e.hasMoreElements()) zf.getInputStream(e.nextElement()); return true; } catch (IOException ex) { return false; }

Type guard

boolean isHealthyJar(Path p) { try (var zf = new java.util.zip.ZipFile(p.toFile())) { return true; } catch (IOException e) { return false; } }

Try / catch

try { app.start(); } catch (RuntimeException e) { if (e.getMessage() != null && e.getMessage().startsWith("Failed to read zip entry")) { log.error("Jar IO failure: {}", e.getMessage(), e.getCause()); throw new IllegalStateException("Corrupt jar or filesystem issue — redeploy", e); } throw e; }

Prevention

When it happens

Trigger: apply calls jarFile.getInputStream(entry) / reads it and any IOException occurs: invalid entry reference, CRC mismatch, IO error on the underlying file during read.

Common situations: Jar damaged by an interrupted transfer or disk fault; jar deleted/replaced while the classloader still has it open; filesystem errors on the host (full disk, failing mount).

Related errors


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