apache/maven · error · ProjectBuilderException

Unable to build project

Error message

Unable to build project

What it means

ProjectBuilderException with message 'Unable to build project' wraps any ProjectBuildingException raised by the underlying legacy project builder while reading or making a POM effective. The DefaultProjectBuilder (Maven API service) delegates to the old builder and rethrows with this generic message; the real diagnostics (bad XML, unresolvable parent, invalid coordinates, model problems) are always in the cause chain.

Source

Thrown at impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultProjectBuilder.java:196

                        }

                        @Override
                        public Severity getSeverity() {
                            return Severity.valueOf(problem.getSeverity().name());
                        }
                    };
                }

                @Nonnull
                @Override
                public Optional<DependencyResolverResult> getDependencyResolverResult() {
                    return Optional.ofNullable(res.getDependencyResolutionResult())
                            .map(r -> new DefaultDependencyResolverResult(
                                    null, r.getCollectionErrors(), session.getNode(r.getDependencyGraph()), 0));
                }
            };
        } catch (ProjectBuildingException e) {
            throw new ProjectBuilderException("Unable to build project", e);
        } finally {
            RequestTraceHelper.exit(trace);
        }
    }

    private static class SourceWrapper implements ModelSource2 {
        private final Source source;

        SourceWrapper(Source source) {
            this.source = source;
        }

        @Override
        public InputStream getInputStream() throws IOException {
            return source.openStream();
        }

        @Override

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Unwrap the cause: ProjectBuilderException.getCause() is a ProjectBuildingException whose results carry ModelProblems with file/line details
  2. Fix the reported POM issues (XML syntax, parent coordinates, version format)
  3. Ensure the request/session carries the remote repositories that host the unresolvable parent
Defensive patterns

Strategy: try-catch

Validate before calling

// Cheap pre-checks before building via the API
if (request.getPath().isPresent() && !Files.isReadable(request.getPath().get())) {
    throw new IllegalArgumentException("POM not readable: " + request.getPath().get());
}

Try / catch

try {
    ProjectBuilderResult result = pb.build(request);
} catch (ProjectBuilderException e) {
    ProjectBuildingException pbe = (ProjectBuildingException) e.getCause();
    for (ProjectBuildingResult r : pbe.getResults()) {
        r.getProblems().forEach(p ->
            log.error("{}:{}:{} {}", p.getSource(), p.getLineNumber(), p.getColumnNumber(), p.getMessage()));
    }
}

Prevention

When it happens

Trigger: Session.getService(ProjectBuilder.class).build(request) where the target POM is malformed, its parent cannot be resolved from the repositories in the request/session, or model validation rejects the effective model.

Common situations: Broken pom.xml committed to the repo; parent POM published to a repository not included in the request's repository list; embedder/API code building poms without the repositories needed to resolve parents; syntactically invalid XML.

Related errors


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