quarkusio/quarkus · error · BootstrapMavenException

Failed to locate project pom.xml for ${path}

Error message

Failed to locate project pom.xml for ${path}

What it means

LocalProject.locateCurrentProjectPom walks up the directory tree from the given path looking for a pom.xml. When `required` is true and no pom.xml is found at or above the path (up to the filesystem root), it throws BootstrapMavenException. This guard exists because the workspace resolver can only operate on an application that is part of a Maven project.

Source

Thrown at independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/LocalProject.java:168

            final Model model = ModelUtils.readModel(pom);
            model.setPomFile(pom.toFile());
            return model;
        } catch (IOException e) {
            throw new BootstrapMavenException("Failed to read " + pom, e);
        }
    }

    static Path locateCurrentProjectPom(Path path, boolean required) throws BootstrapMavenException {
        Path p = path;
        while (p != null) {
            final Path pom = p.resolve(POM_XML);
            if (Files.exists(pom)) {
                return pom;
            }
            p = p.getParent();
        }
        if (required) {
            throw new BootstrapMavenException("Failed to locate project pom.xml for " + path);
        }
        return null;
    }

    private final Model rawModel;
    private final Model effectiveModel;
    private final ModelBuildingResult modelBuildingResult;
    private final ArtifactKey key;
    private String version;
    private final Path dir;
    private final LocalWorkspace workspace;
    private volatile LocalProject parent;
    private volatile WorkspaceModule module;

    /**
     * TODO: linking LocalProject to a ModelBuildingResult is probably not a good idea.
     * Perhaps, the result should be cached in the MavenModelBuilder instead.
     *

View on GitHub (pinned to e1c734241f)

Solutions

  1. Run the bootstrap from a directory that contains a pom.xml (or one of its subdirectories); verify with `ls pom.xml` from the working directory.
  2. If the path may legitimately have no project, use the non-required lookup (or catch BootstrapMavenException) and fall back to resolving the artifact from the repository instead of the workspace.
  3. Restore or recreate the deleted/misplaced pom.xml, or fix the configured project path (e.g. quarkus workspace/project dir or `-f pom.xml` style options).

Example fix

// before (running from a dir with no pom)
Path dir = Path.of("/tmp/junk");
LocalProject project = LocalProject.load(dir); // throws BootstrapMavenException
// after
Path dir = Path.of("/work/my-app"); // contains pom.xml
if (!Files.exists(dir.resolve("pom.xml"))) {
    throw new IllegalArgumentException("Not a Maven project dir: " + dir);
}
LocalProject project = LocalProject.load(dir);
Defensive patterns

Strategy: validation

Validate before calling

static Path requireProjectPom(Path dir) throws IOException {
    Path p = dir.toAbsolutePath();
    while (p != null) {
        if (Files.exists(p.resolve("pom.xml"))) return p.resolve("pom.xml");
        p = p.getParent();
    }
    throw new IllegalArgumentException("No pom.xml found at or above " + dir);
}

Type guard

static boolean isMavenProjectDir(Path dir) {
    return dir != null && Files.isDirectory(dir) && Files.exists(dir.resolve("pom.xml"));
}

Try / catch

try {
    LocalProject project = LocalProject.load(dir);
} catch (BootstrapMavenException e) {
    // fall back to repository resolution or fail with a clear message
    log.warn("Not a Maven project: " + dir);
}

Prevention

When it happens

Trigger: Calling LocalProject.get...()/locateCurrentProjectPom with `required=true` for a path that is not inside any Maven project directory, e.g. an arbitrary temp dir, a directory whose pom.xml was deleted, or a path that is a plain JAR file outside a project tree.

Common situations: Running a Quarkus dev-mode/test bootstrap from a directory that is not a Maven project root or module; passing a path to a JAR or a file instead of a project directory; a renamed/moved pom.xml; invoking tooling from the filesystem root or home dir with no pom.xml anywhere above it.

Related errors


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