quarkusio/quarkus · critical · RuntimeException

Failed to open ${jarResource.jarPath}

Error message

Failed to open ${jarResource.jarPath}

What it means

Runtime exception from JarFileReference.syncLoadAcquiredJarFile in the Quarkus runner: after joining the future that opens a nested jar, the jar file at the given path could not be opened (it disappeared, is unreadable, or was corrupted). The jar path is interpolated into the message; this is the synchronous fallback path when lazy reopening fails.

Source

Thrown at independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/JarFileReference.java:195

        JarFileReference jarFileReference = jarFileReferenceFuture.join();
        try {
            return fileConsumer.apply(jarFileReference.jarFile, jarResource.jarPath, resource);
        } finally {
            boolean closed = jarFileReference.release(jarResource);
            assert !closed;
            // Check one last time if the file reference can be published and reused by other threads, otherwise close it
            if (!jarResource.jarFileReference.compareAndSet(null, jarFileReferenceFuture)) {
                jarFileReference.markForClosing(jarResource);
            }
        }
    }

    private static CompletableFuture<JarFileReference> syncLoadAcquiredJarFile(JarResource jarResource) {
        try {
            return new JarFileReference(JarFiles.create(jarResource.jarPath.toFile()),
                    new CompletableFuture<>()).completedFuture;
        } catch (IOException e) {
            throw new RuntimeException("Failed to open " + jarResource.jarPath, e);
        }
    }

    private static JarFileReference asyncLoadAcquiredJarFile(JarResource jarResource) {
        CompletableFuture<JarFileReference> newJarRefFuture = new CompletableFuture<>();
        CompletableFuture<JarFileReference> existingJarRefFuture = null;
        JarFileReference existingJarRef = null;

        do {
            if (jarResource.jarFileReference.compareAndSet(null, newJarRefFuture)) {
                try {
                    return new JarFileReference(JarFiles.create(jarResource.jarPath.toFile()), newJarRefFuture);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            existingJarRefFuture = jarResource.jarFileReference.get();
            existingJarRef = existingJarRefFuture == null ? null : existingJarRefFuture.join();

View on GitHub (pinned to e1c734241f)

Solutions

  1. Verify the named jar exists and is readable: ls -l and unzip -t <jarPath>.
  2. Rebuild/redeploy the application (mvn clean package) to restore a complete lib directory.
  3. Ensure the deploying process finishes copying jars before the app starts (no partial uploads).
  4. Check for another process holding a lock on the jar (Windows) or a stale/deleted mount.

Example fix

// before
deploy.sh  # rsync without --delay-updates, app starts on partial tree
// after
rsync -a --delay-updates app/ /deploy/app/ && /deploy/app/quarkus-run
Defensive patterns

Strategy: validation

Validate before calling

Path jar = Path.of(jarPath);
if (!Files.isRegularFile(jar) || Files.size(jar) == 0 || !Files.isReadable(jar)) throw new IllegalStateException("bad jar: " + jar);
try (var zf = new java.util.zip.ZipFile(jar.toFile())) { /* opens OK */ }

Type guard

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

Try / catch

try { app.start(); } catch (RuntimeException e) { if (e.getMessage() != null && e.getMessage().startsWith("Failed to open ")) { log.error("Cannot open jar: {}", e.getMessage(), e.getCause()); throw new IllegalStateException("Redeploy application", e); } throw e; }

Prevention

When it happens

Trigger: syncLoadAcquiredJarFile (invoked via newJarFileRef) calls JarFiles.create(jarResource.jarPath.toFile()) and the jar cannot be opened — file missing, unreadable, not a valid zip, or locked by another process.

Common situations: lib/ directory incomplete after a partial copy/deploy; jar replaced or deleted while running; disk or network mount failure; jar truncated by an interrupted build or download.

Related errors


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