{"record":{"id":"ae3cd5512db85aeb","repo":"quarkusio/quarkus","slug":"unable-to-read-file-relativepath","errorCode":null,"errorMessage":"Unable to read file: ${relativePath}","messagePattern":"Unable to read file: (.+?)","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/AotSerializedApplication.java","lineNumber":253,"sourceCode":"            try (var is = jarFile.getInputStream(fileEntry)) {\n                serviceFiles.computeIfAbsent(fileEntry.getName(), k -> new ArrayList<>())\n                        .add(is.readAllBytes());\n            } catch (IOException e) {\n                throw new UncheckedIOException(\"Unable to read entry: \" + fileEntry.getName() + \" from jar: \" + jarFile, e);\n            }\n        }\n\n        @Override\n        public void visitRegularFile(Path jar, Path file, String relativePath) {\n            if (!isServiceFile(relativePath)) {\n                return;\n            }\n\n            try {\n                serviceFiles.computeIfAbsent(relativePath, k -> new ArrayList<>())\n                        .add(Files.readAllBytes(file));\n            } catch (IOException e) {\n                throw new UncheckedIOException(\"Unable to read file: \" + relativePath, e);\n            }\n        }\n\n        private static boolean isServiceFile(String resourcePath) {\n            return resourcePath.startsWith(\"META-INF/services/\") && resourcePath.length() > 18;\n        }\n    }\n\n    private static class ApplicationConfigFileJarVisitor implements JarVisitor {\n\n        private final Map<String, List<ApplicationConfigEntry>> applicationConfigFiles = new LinkedHashMap<>();\n\n        public Map<String, List<ApplicationConfigEntry>> getApplicationConfigFiles() {\n            return applicationConfigFiles;\n        }\n\n        @Override\n        public void visitJarFileEntry(JarFile jarFile, ZipEntry fileEntry) {","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/AotSerializedApplication.java#L235-L271","documentation":"Thrown as an UncheckedIOException while the AOT serializer's file visitor reads a service file (META-INF/services/*) from an exploded application directory via Files.readAllBytes. It indicates an I/O problem (missing file, permissions, race/deletion) while snapshotting service loader descriptors during application serialization.","triggerScenarios":"AotSerializedApplication serialization walks an application directory and a regular file under META-INF/services/ (length > 18) cannot be read: file deleted between listing and reading, unreadable permissions, symlink to nonexistent target, or underlying filesystem error.","commonSituations":"Running in a container where the classpath directory is being concurrently rebuilt; restrictive file permissions after packaging; broken symlinks in target/ directories; antivirus/indexing tools briefly locking files on Windows.","solutions":["Verify the file at the reported relativePath exists and is readable by the user running the app (ls -l).","Re-run a clean build (mvn clean package) to remove stale/broken files in the output directory.","Exclude broken symlinks or regenerate the service file; check META-INF/services entries are real files.","Check for concurrent processes modifying the directory during AOT serialization."],"exampleFix":"// before (failing)\nFiles.readAllBytes(file);\n// after (defensive check in build/packaging script)\nif (!Files.isReadable(file) || Files.size(file) < 0) { throw new IllegalStateException(\"unreadable service file: \" + file); }","handlingStrategy":"validation","validationCode":"Path f = dir.resolve(relativePath);\nif (!Files.isRegularFile(f) || !Files.isReadable(f)) throw new IllegalStateException(\"unreadable service file: \" + relativePath);","typeGuard":"boolean isReadableRegularFile(Path p) { return p != null && Files.isRegularFile(p) && Files.isReadable(p); }","tryCatchPattern":"try { /* serialization run */ } catch (UncheckedIOException e) { if (e.getMessage().startsWith(\"Unable to read file\")) { log.error(\"Service file unreadable: rebuild app\", e); throw new IllegalStateException(\"Fix classpath directory and rebuild\", e); } throw e; }","preventionTips":["Run clean builds so output directories contain no stale or broken files.","Check file permissions of quarkus-app directories before launch.","Avoid concurrent modification of the app directory during serialization.","Exclude broken symlinks from packaging."],"tags":["io","serialization","unchecked-io-exception"],"backgroundTag":"file-read-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}