quarkusio/quarkus · error · IllegalArgumentException

File ${p} does not exist

Error message

File ${p} does not exist

What it means

CatalogMapperHelper.deserialize(ObjectMapper, Path, Class) guards all catalog JSON deserialization with a Files.exists(p) check and throws IllegalArgumentException when the file is missing. The library expects every catalog/registry JSON artifact (platform, non-platform, categories) to be materialized on disk before mapping.

Source

Thrown at independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/catalog/CatalogMapperHelper.java:85

            serialize(mapper, catalog, writer);
        }
    }

    public static void serialize(Object catalog, Writer writer) throws IOException {
        serialize(mapper(), catalog, writer);
    }

    public static void serialize(ObjectMapper mapper, Object catalog, Writer writer) throws IOException {
        mapper.writeValue(writer, catalog);
    }

    public static <T> T deserialize(Path p, Class<T> t) throws IOException {
        return deserialize(mapperForPath(p), p, t);
    }

    public static <T> T deserialize(ObjectMapper mapper, Path p, Class<T> t) throws IOException {
        if (!Files.exists(p)) {
            throw new IllegalArgumentException("File " + p + " does not exist");
        }
        try (BufferedReader reader = Files.newBufferedReader(p)) {
            return mapper.readValue(reader, t);
        }
    }

    public static <T> T deserialize(InputStream is, Class<T> t) throws IOException {
        return deserialize(mapper(), is, t);
    }

    public static <T> T deserialize(ObjectMapper mapper, InputStream is, Class<T> t) throws IOException {
        return mapper.readValue(is, t);
    }

    public static <T> T deserialize(Reader reader, Class<T> t) throws IOException {
        return deserialize(mapper(), reader, t);
    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Check Files.exists(path) and print the absolute path to verify the expected location.
  2. Fix the path/coordinates so the catalog file actually exists (mvn resolve or re-download the artifact).
  3. Repopulate the cache (clear and re-run resolution) if a cached path is stale.
  4. Use the ObjectMapper deserialize variant only after ensuring the file was written, or handle IllegalArgumentException explicitly.

Example fix

// before
var catalog = CatalogMapperHelper.deserialize(mapper, jsonPath, ExtensionCatalogImpl.class);
// after
if (!Files.exists(jsonPath)) {
    jsonPath = downloadCatalog(artifactCoords); // materialize first
}
var catalog = CatalogMapperHelper.deserialize(mapper, jsonPath, ExtensionCatalogImpl.class);
Defensive patterns

Strategy: validation

Validate before calling

// Java
import java.nio.file.*;
if (p == null || !Files.isRegularFile(p)) {
    throw new IllegalStateException("Catalog file missing: " + (p == null ? "null" : p.toAbsolutePath()));
}

Try / catch

// Java
try {
    T catalog = CatalogMapperHelper.deserialize(mapper, p, clazz);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("File ") && e.getMessage().endsWith(" does not exist")) {
        // materialize/redownload the file at path e.getMessage() refers to
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling deserialize()/deserialize(mapper, p, t) (e.g. ExtensionCatalog.fromFile, CodeCatalog, recommendations loading) with a Path that does not exist — typically a downloaded artifact that failed to land, a wrong local path, or a cache dir that was cleared.

Common situations: Pointing a resolver at a local JSON file whose path is mistyped; Maven artifact download skipped/failed but code proceeds; stale cache references after ~/.m2 or registry-cache cleanup; relative path resolved against unexpected working directory.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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