apache/maven · error · IllegalArgumentException

Not a regular file: ${path}

Error message

Not a regular file: ${path}

What it means

ModelBuilder.getRawModel(Path from, Path path) reads a raw (uninherited) model from a file-system path. Before reading, it requires Files.isRegularFile(path): a directory, a missing file, a dangling symlink, or a special file (FIFO/device) is rejected with IllegalArgumentException instead of a confusing read error.

Source

Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelBuilder.java:427

        public Model getRawModel(Path from, String groupId, String artifactId) {
            ModelSource source = getSource(groupId, artifactId);
            if (source != null) {
                if (addEdge(from, source.getPath())) {
                    return null;
                }
                try {
                    return derive(source).readRawModel();
                } catch (ModelBuilderException e) {
                    // gathered with problem collector
                }
            }
            return null;
        }

        public Model getRawModel(Path from, Path path) {
            if (!Files.isRegularFile(path)) {
                throw new IllegalArgumentException("Not a regular file: " + path);
            }
            if (addEdge(from, path)) {
                return null;
            }
            try {
                return derive(Sources.buildSource(path)).readRawModel();
            } catch (ModelBuilderException e) {
                // gathered with problem collector
            }
            return null;
        }

        /**
         * Returns false if the edge was added, true if it caused a cycle.
         */
        private boolean addEdge(Path from, Path p) {
            try {
                dag.addEdge(from.toString(), p.toString());

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Set <relativePath> to the actual pom file (e.g. ../pom.xml) or remove the element so the default ../pom.xml lookup applies
  2. Verify the file exists and is a regular file (ls -l) and fix symlinks
  3. If calling getRawModel directly, guard the call with Files.isRegularFile(path)
  4. Refresh/re-import the project in the IDE so stale paths are re-resolved

Example fix

<!-- before -->
<parent>
  <groupId>com.acme</groupId>
  <artifactId>parent</artifactId>
  <relativePath>../some-module</relativePath>
</parent>

<!-- after -->
<parent>
  <groupId>com.acme</groupId>
  <artifactId>parent</artifactId>
  <relativePath>../pom.xml</relativePath>
</parent>
Defensive patterns

Strategy: validation

Validate before calling

if (path == null || !Files.isRegularFile(path)) {
    // skip or report instead of calling getRawModel(from, path)
    throw new IllegalArgumentException("Pom path is not a regular file: " + path);
}
Model raw = modelBuilder.getRawModel(from, path);

Try / catch

try {
    Model raw = modelBuilder.getRawModel(from, path);
} catch (IllegalArgumentException e) {
    // path was a directory / missing / dangling symlink; recompute or skip
}

Prevention

When it happens

Trigger: A <parent><relativePath> that resolves to a directory instead of a pom file; calling getRawModel(from, path) with a directory path; a symlinked module whose target has been moved or deleted.

Common situations: relativePath set to '..' or to a module directory rather than '../pom.xml'; scripts or embedders passing <dir>/some-module instead of <dir>/some-module/pom.xml; files moved/deleted while an IDE or daemon still holds stale paths.

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/073589befaad165d. Report an issue: GitHub.