quarkusio/quarkus · error · BootstrapMavenException

Failed to locate project pom.xml for

Error message

Failed to locate project pom.xml for 

What it means

WorkspaceLoader.locateCurrentProjectPom(Path) climbs from the given path to the filesystem root looking for pom.xml. If none is found it throws BootstrapMavenException. The loader requires the current project POM to anchor the workspace module graph.

Source

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

            // which we don't support in this workspace loader
            log.warn("Module(s) under " + pom.getParent() + " will be handled as thirdparty dependencies because " + pom
                    + " does not exist");
            return MISSING_MODEL;
        } catch (IOException e) {
            throw new UncheckedIOException("Failed to load POM from " + pom, e);
        }
    }

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

    private final Deque<WorkspaceModulePom> loadQueue = new ConcurrentLinkedDeque<>();
    // Map key is the normalized absolute Path to the module directory
    private final Map<Path, WorkspaceModulePom> knownModules = new ConcurrentHashMap<>();
    private final Map<GAV, Model> loadedModules = new ConcurrentHashMap<>();
    private final Consumer<WorkspaceModulePom> loadedModelProcessor;

    private final LocalWorkspace workspace = new LocalWorkspace();
    private final Path currentProjectPom;
    private volatile LocalProject currentProject;

    WorkspaceLoader(BootstrapMavenContext ctx, Path currentProjectPom, List<WorkspaceModulePom> providedModules)
            throws BootstrapMavenException {
        try {
            final BasicFileAttributes fileAttributes = Files.readAttributes(currentProjectPom, BasicFileAttributes.class);
            this.currentProjectPom = fileAttributes.isDirectory() ? locateCurrentProjectPom(currentProjectPom)
                    : currentProjectPom;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Run from the application (module or root) directory that contains pom.xml, or point the bootstrap's project path at it.
  2. Restore the missing pom.xml (`git checkout -- pom.xml` or recreate it).
  3. Disable workspace resolution if the app is not a Maven project (quarkus.workspace-discovery=false / not enabling the multi-module flag).
  4. Catch BootstrapMavenException and fall back to repository-based resolution if workspace loading is optional.

Example fix

// before
ProcessBuilder pb = new ProcessBuilder("mvn", "quarkus:dev");
pb.directory(new File("/tmp")); // no pom.xml anywhere above
// after
pb.directory(new File("/work/my-app")); // contains pom.xml
Defensive patterns

Strategy: validation

Validate before calling

static Path requireAncestorPom(Path dir) {
    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 in " + dir + " or any parent directory");
}

Type guard

static boolean isInsideMavenProject(Path dir) {
    Path p = dir == null ? null : dir.toAbsolutePath();
    while (p != null) {
        if (Files.exists(p.resolve("pom.xml"))) return true;
        p = p.getParent();
    }
    return false;
}

Try / catch

try {
    WorkspaceLoader loader = ctx.newWorkspaceLoader(...);
} catch (BootstrapMavenException e) {
    // no pom.xml at or above the given path — disable workspace resolution or fix path
}

Prevention

When it happens

Trigger: Constructing a WorkspaceLoader (via BootstrapMavenContext) with currentProjectPom pointing at a directory with no pom.xml in it or any ancestor directory — e.g. the maven multi-module flag is on but the working dir is outside any Maven project.

Common situations: Launching Quarkus dev mode or tests from a random directory (e.g. /tmp, $HOME); the project's pom.xml deleted or renamed (pom.xml.orig); passing a directory that only contains build output; running inside a container with only sources mounted without pom.xml.

Related errors


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