{"record":{"id":"3971d8440273c765","repo":"quarkusio/quarkus","slug":"failed-to-locate-directory-dir","errorCode":null,"errorMessage":"Failed to locate directory <dir>","messagePattern":"Failed to locate directory <dir>","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/descriptor/loader/json/DirectoryResourceLoader.java","lineNumber":13,"sourceCode":"package io.quarkus.platform.descriptor.loader.json;\n\nimport java.io.IOException;\nimport java.nio.file.Files;\nimport java.nio.file.Path;\n\npublic class DirectoryResourceLoader implements ResourceLoader {\n\n    private final Path dir;\n\n    public DirectoryResourceLoader(Path dir) {\n        if (!Files.isDirectory(dir)) {\n            throw new IllegalStateException(\"Failed to locate directory \" + dir);\n        }\n        this.dir = dir;\n    }\n\n    @Override\n    public <T> T loadResourceAsPath(String name, ResourcePathConsumer<T> consumer) throws IOException {\n        Path path = dir.resolve(name);\n        if (!Files.exists(path)) {\n            throw new IOException(\"Failed to locate \" + name + \" dir on the classpath\");\n        }\n        return consumer.consume(path);\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/descriptor/loader/json/DirectoryResourceLoader.java#L1-L27","documentation":"DirectoryResourceLoader's constructor validates that the given Path is an existing directory and throws IllegalStateException immediately otherwise. The loader is being constructed against a path that doesn't exist or is a regular file.","triggerScenarios":"new DirectoryResourceLoader(dir) where dir is missing, deleted, points to a file, or has a typo (unresolved symlink, wrong working directory).","commonSituations":"Local platform descriptor checkout path misconfigured; running from a different working directory than expected; directory removed by a clean build before tooling runs.","solutions":["Verify the path exists and is a directory (Files.isDirectory) before constructing","Fix the configured path/working directory","Create the directory if it is supposed to exist","If the source may be a jar/zip instead, use ResourceLoaders.resolveFileResourceLoader which picks the right loader"],"exampleFix":"// before\nnew DirectoryResourceLoader(Path.of(\"maybe-missing\"));\n// after\nPath p = Path.of(\"maybe-missing\");\nif (Files.isDirectory(p)) {\n    new DirectoryResourceLoader(p);\n} else {\n    ResourceLoaders.resolveFileResourceLoader(p.toFile());\n}","handlingStrategy":"validation","validationCode":"Path dir = Path.of(configuredPath);\nif (!Files.isDirectory(dir)) {\n    throw new IllegalArgumentException(\"Not a directory: \" + dir.toAbsolutePath());\n}","typeGuard":"boolean isUsableResourceDir(Path p) {\n    return p != null && Files.isDirectory(p);\n}","tryCatchPattern":"try {\n    loader = new DirectoryResourceLoader(dir);\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"Failed to locate directory\")) {\n        throw new ConfigurationException(\"Configured descriptor directory does not exist: \" + dir, e);\n    }\n    throw e;\n}","preventionTips":["Log/verify absolute paths — relative paths depend on the working directory","Create or check out the directory before constructing the loader","Validate configured paths at startup, not lazily"],"tags":["filesystem","validation","resource-loading"],"backgroundTag":"directory-not-found","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"}