apache/maven · warning

Failed to build parent project for {}

Error message

Failed to build parent project for {}

What it means

While assembling a project's effective model, DefaultProjectBuilder recursively builds the <parent>. Under the MNG-4488 policy an invalid parent does not abort the child: ProjectBuildingException is caught, this warning is logged, and building continues with parent = null. This variant is the debug-enabled form for the branch where the parent is backed by a pom.xml file (resolved via relativePath, parentPomFile != null); the message text is deliberately stable because MNG-2199 core ITs assert on it.

Source

Thrown at impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java:1078

                            throw new IllegalArgumentException(
                                    "Unsupported repository merging: " + request.getRepositoryMerging());
                    }

                    // Store the computed repositories for this project in BuildSession storage
                    // to avoid mutating the shared request and causing leakage between projects
                    projectRepositories.put(project.getId(), mergedRepositories);

                    Path parentPomFile = parentModel.getPomFile();
                    if (parentPomFile != null) {
                        project.setParentFile(parentPomFile.toFile());
                        try {
                            parent = build(true, parentPomFile, Sources.buildSource(parentPomFile))
                                    .getProject();
                        } catch (ProjectBuildingException e) {
                            // MNG-4488 where let invalid parents slide on by
                            if (logger.isDebugEnabled()) {
                                // Message below is checked for in the MNG-2199 core IT.
                                logger.warn("Failed to build parent project for " + project.getId(), e);
                            } else {
                                // Message below is checked for in the MNG-2199 core IT.
                                logger.warn("Failed to build parent project for " + project.getId());
                            }
                        }
                    } else {
                        Artifact parentArtifact = project.getParentArtifact();
                        try {
                            parent = build(true, parentArtifact, false, getEffectiveRepositories(project.getId()))
                                    .getProject();
                        } catch (ProjectBuildingException e) {
                            // MNG-4488 where let invalid parents slide on by
                            if (logger.isDebugEnabled()) {
                                // Message below is checked for in the MNG-2199 core IT.
                                logger.warn("Failed to build parent project for " + project.getId(), e);
                            } else {
                                // Message below is checked for in the MNG-2199 core IT.
                                logger.warn("Failed to build parent project for " + project.getId());

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Run with -X and read the appended ProjectBuildingException - it states the real reason the parent failed to build; fix that first
  2. Verify <parent> coordinates and <relativePath>: point it at the real parent file, or set <relativePath/> (empty) to force repository resolution instead of the filesystem
  3. If the parent must come from a repository, make sure it is installed/deployed (mvn -N install in the parent directory) and reachable with -U
  4. Do not ignore the degraded state: without the parent, effective-model correctness is not guaranteed - expect and chase follow-up errors

Example fix

<!-- before: default relativePath ../pom.xml does not point at the real parent -->
<parent>
  <groupId>com.corp</groupId>
  <artifactId>corp-parent</artifactId>
  <version>2.1</version>
</parent>
<!-- after: empty relativePath forces repository lookup for the parent -->
<parent>
  <groupId>com.corp</groupId>
  <artifactId>corp-parent</artifactId>
  <version>2.1</version>
  <relativePath/>
</parent>
Defensive patterns

Strategy: validation

Validate before calling

# preflight: the parent referenced at relativePath must exist and parse
child=pom.xml
rel=$(xmllint --xpath 'string(/*[local-name()="project"]/*[local-name()="parent"]/*[local-name()="relativePath"])' "$child")
rel=${rel:-../pom.xml}
test -f "$rel" && xmllint --noout "$rel" && echo parent-ok || echo "parent file missing/invalid at $rel"

Prevention

When it happens

Trigger: A module whose <parent><relativePath> (default ../pom.xml) points at a POM that itself fails to build - malformed XML, unresolvable ITS parent, invalid model - during any reactor build, with -X enabled so the stack trace prints. The child continues but loses the parent's packaging, properties, dependencyManagement and pluginManagement.

Common situations: relativePath left at default while the parent sits elsewhere; a parent POM edited and broken locally; refactors where the parent file moved; consequences surface later as missing properties or 'Invalid packaging' errors far from the cause.

Related errors


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