quarkusio/quarkus · error · java.lang.IllegalArgumentException

does not exist

Error message

 does not exist

What it means

PathTree.ofDirectoryOrFile() stats the given path to decide whether to build a DirectoryPathTree or a FilePathTree. If reading the file attributes fails (the path does not exist or is not accessible), it throws IllegalArgumentException '<p> does not exist' wrapping the IOException.

Source

Thrown at independent-projects/bootstrap/app-model/src/main/java/io/quarkus/paths/PathTree.java:27

import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;

/**
 * Classpath resource set backed by file system paths.
 */
public interface PathTree {

    static PathTree ofDirectoryOrFile(Path p) {
        return ofDirectoryOrFile(p, null);
    }

    static PathTree ofDirectoryOrFile(Path p, PathFilter filter) {
        try {
            final BasicFileAttributes fileAttributes = Files.readAttributes(p, BasicFileAttributes.class);
            return fileAttributes.isDirectory() ? new DirectoryPathTree(p, filter) : new FilePathTree(p, filter);
        } catch (IOException e) {
            throw new IllegalArgumentException(p + " does not exist", e);
        }
    }

    /**
     * Creates a new {@link PathTree} for a given existing path which is expected to be
     * either a directory or a ZIP-based archive.
     *
     * @param p path to a directory or an archive
     * @return an instance of {@link PathTree} for a given existing directory or an archive
     */
    static PathTree ofDirectoryOrArchive(Path p) {
        return ofDirectoryOrArchive(p, null);
    }

    /**
     * Creates a new {@link PathTree} for a given existing path which is expected to be
     * either a directory or a ZIP-based archive applying a provided {@link PathFilter}
     * unless it is {@code null}.

View on GitHub (pinned to e1c734241f)

Solutions

  1. Check Files.exists(p) before calling ofDirectoryOrFile and produce a clear error naming the missing path.
  2. Fix the path value (verify with Files.exists / print it) — often a wrong working directory or unresolved variable.
  3. Create the missing file/directory if it should exist by then.
  4. Catch IllegalArgumentException from ofDirectoryOrFile if absence is a supported case and fall back.

Example fix

// before
PathTree tree = PathTree.ofDirectoryOrFile(cfg.outputDir, null); // IllegalArgumentException if absent
// after
if (!Files.exists(cfg.outputDir)) {
    throw new IllegalStateException("Configured outputDir does not exist: " + cfg.outputDir);
}
PathTree tree = PathTree.ofDirectoryOrFile(cfg.outputDir, null);
Defensive patterns

Strategy: validation

Validate before calling

if (p == null || !Files.exists(p)) {
    throw new IllegalStateException("Path does not exist: " + p);
}

Type guard

static boolean isExistingPath(Path p) {
    return p != null && Files.exists(p);
}

Try / catch

try {
    PathTree tree = PathTree.ofDirectoryOrFile(p, filter);
} catch (IllegalArgumentException e) {
    log.warnf("Skipping non-existent path: %s", p);
    return PathTree.EMPTY;
}

Prevention

When it happens

Trigger: Calling PathTree.ofDirectoryOrFile(p, filter) with a Path that does not exist on disk (typo, wrong working directory, file deleted, unresolved placeholder in the path).

Common situations: Hardcoded absolute paths that differ between machines/CI; a resource directory not created by the build; running from a different working directory than expected; typos in configured output directories.

Related errors


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