quarkusio/quarkus · error · IOException

Failed to locate <name> dir on the classpath

Error message

Failed to locate <name> dir on the classpath

What it means

DirectoryResourceLoader.loadResourceAsPath resolves `name` inside the loader's root directory and throws IOException if the resolved path doesn't exist. The root dir is valid but the specific requested resource is missing inside it.

Source

Thrown at independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/descriptor/loader/json/DirectoryResourceLoader.java:22

import java.nio.file.Files;
import java.nio.file.Path;

public class DirectoryResourceLoader implements ResourceLoader {

    private final Path dir;

    public DirectoryResourceLoader(Path dir) {
        if (!Files.isDirectory(dir)) {
            throw new IllegalStateException("Failed to locate directory " + dir);
        }
        this.dir = dir;
    }

    @Override
    public <T> T loadResourceAsPath(String name, ResourcePathConsumer<T> consumer) throws IOException {
        Path path = dir.resolve(name);
        if (!Files.exists(path)) {
            throw new IOException("Failed to locate " + name + " dir on the classpath");
        }
        return consumer.consume(path);
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. List the root directory and confirm the exact resource filename (watch case sensitivity)
  2. Regenerate or download the resource into the directory
  3. Use the correct versioned file name matching your platform version
  4. Check the loader's root dir is the one you intend

Example fix

// before
loader.loadResourceAsPath("quarkus-bom-descriptor.json", c); // file is actually versioned
// after
loader.loadResourceAsPath("io/quarkus/platform/descriptor/json/quarkus-bom-quarkus-platform-descriptor-3.2.0.json", c);
Defensive patterns

Strategy: validation

Validate before calling

Path resolved = rootDir.resolve(name);
if (!Files.exists(resolved)) {
    throw new IllegalArgumentException("Missing resource in dir: " + resolved);
}

Type guard

boolean dirContains(Path root, String name) {
    return Files.exists(root.resolve(name));
}

Try / catch

try {
    return loader.loadResourceAsPath(name, consumer);
} catch (IOException e) {
    if (e.getMessage().contains("dir on the classpath")) {
        throw new MissingDescriptorException(name, e);
    }
    throw e;
}

Prevention

When it happens

Trigger: loadResourceAsPath(name, consumer) where dir/name is absent — wrong relative name, resource not yet generated, or case-sensitivity mismatch on Linux filesystems.

Common situations: Requesting a descriptor JSON from a local platform checkout that uses a different versioned filename; case-sensitive filesystem mismatch (Desc.json vs desc.json); file deleted between loader creation and use.

Related errors


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