{"record":{"id":"bb058dc3e8d2e267","repo":"quarkusio/quarkus","slug":"failed-to-open-jarresource-jarpath","errorCode":null,"errorMessage":"Failed to open ${jarResource.jarPath}","messagePattern":"Failed to open (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/JarFileReference.java","lineNumber":195,"sourceCode":"        JarFileReference jarFileReference = jarFileReferenceFuture.join();\n        try {\n            return fileConsumer.apply(jarFileReference.jarFile, jarResource.jarPath, resource);\n        } finally {\n            boolean closed = jarFileReference.release(jarResource);\n            assert !closed;\n            // Check one last time if the file reference can be published and reused by other threads, otherwise close it\n            if (!jarResource.jarFileReference.compareAndSet(null, jarFileReferenceFuture)) {\n                jarFileReference.markForClosing(jarResource);\n            }\n        }\n    }\n\n    private static CompletableFuture<JarFileReference> syncLoadAcquiredJarFile(JarResource jarResource) {\n        try {\n            return new JarFileReference(JarFiles.create(jarResource.jarPath.toFile()),\n                    new CompletableFuture<>()).completedFuture;\n        } catch (IOException e) {\n            throw new RuntimeException(\"Failed to open \" + jarResource.jarPath, e);\n        }\n    }\n\n    private static JarFileReference asyncLoadAcquiredJarFile(JarResource jarResource) {\n        CompletableFuture<JarFileReference> newJarRefFuture = new CompletableFuture<>();\n        CompletableFuture<JarFileReference> existingJarRefFuture = null;\n        JarFileReference existingJarRef = null;\n\n        do {\n            if (jarResource.jarFileReference.compareAndSet(null, newJarRefFuture)) {\n                try {\n                    return new JarFileReference(JarFiles.create(jarResource.jarPath.toFile()), newJarRefFuture);\n                } catch (IOException e) {\n                    throw new RuntimeException(e);\n                }\n            }\n            existingJarRefFuture = jarResource.jarFileReference.get();\n            existingJarRef = existingJarRefFuture == null ? null : existingJarRefFuture.join();","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/JarFileReference.java#L177-L213","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the named jar exists and is readable: ls -l and unzip -t <jarPath>.","Rebuild/redeploy the application (mvn clean package) to restore a complete lib directory.","Ensure the deploying process finishes copying jars before the app starts (no partial uploads).","Check for another process holding a lock on the jar (Windows) or a stale/deleted mount."],"exampleFix":"// before\ndeploy.sh  # rsync without --delay-updates, app starts on partial tree\n// after\nrsync -a --delay-updates app/ /deploy/app/ && /deploy/app/quarkus-run","handlingStrategy":"validation","validationCode":"Path jar = Path.of(jarPath);\nif (!Files.isRegularFile(jar) || Files.size(jar) == 0 || !Files.isReadable(jar)) throw new IllegalStateException(\"bad jar: \" + jar);\ntry (var zf = new java.util.zip.ZipFile(jar.toFile())) { /* opens OK */ }","typeGuard":"boolean isOpenableJar(Path p) { try (var zf = new java.util.zip.ZipFile(p.toFile())) { return true; } catch (Exception e) { return false; } }","tryCatchPattern":"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; }","preventionTips":["Use complete, verified copies of the lib directory before launch.","Deploy with rsync --delay-updates or temp+rename for atomicity.","Check file locks on Windows before restart.","Monitor disk space on deploy hosts."],"tags":["io","jar","startup"],"backgroundTag":"jar-open-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}