apache/maven · error · ArtifactMetadataRetrievalException

Failed to retrieve POM for " + artifact.getId() + ": " + e.g

Error message

Failed to retrieve POM for " + artifact.getId() + ": " + e.getCause().getMessage()

What it means

Thrown by MavenMetadataSource when building the POM of an artifact fails with a non-transferable-POM condition: the POM exists in the repository but the transfer itself failed. isNonTransferablePom(e) detects that shape and the ArtifactMetadataRetrievalException is built from e.getCause() (typically a Wagon/resolver transfer error: connection, authentication, authorization or checksum failure), so the original network-level message surfaces.

Source

Thrown at compat/maven-compat/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java:567

                    }
                    configuration.setRepositorySession(legacySupport.getRepositorySession());

                    project = projectBuilder.build(pomArtifact, configuration).getProject();
                } catch (ProjectBuildingException e) {
                    ModelProblem missingParentPom = hasMissingParentPom(e);
                    if (missingParentPom != null) {
                        throw new ArtifactMetadataRetrievalException(
                                "Failed to process POM for " + artifact.getId() + ": " + missingParentPom.getMessage(),
                                missingParentPom.getException(),
                                artifact);
                    }

                    String message;

                    if (isMissingPom(e)) {
                        message = "Missing POM for " + artifact.getId();
                    } else if (isNonTransferablePom(e)) {
                        throw new ArtifactMetadataRetrievalException(
                                "Failed to retrieve POM for " + artifact.getId() + ": "
                                        + e.getCause().getMessage(),
                                e.getCause(),
                                artifact);
                    } else {
                        message = "Invalid POM for " + artifact.getId()
                                + ", transitive dependencies (if any) will not be available"
                                + ", enable verbose output (-X) for more details";
                    }

                    if (logger.isDebugEnabled()) {
                        message += ": " + e.getMessage();
                    }

                    logger.warn(message);
                }

                if (project != null) {

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Check the cause message for the HTTP/status error and fix the corresponding issue (credentials, proxy, URL)
  2. Add/fix <server> credentials in settings.xml for the repository id shown in logs
  3. Whitelist the needed repo from catch-all mirrors (mirrorOf '*,!corp-repo')
  4. Retry after deleting the failed artifact's folder under ~/.m2/repository; use -U to force update checks
  5. If behind a proxy, configure <proxies> in settings.xml or corporate environment variables

Example fix

# before: mirror intercepts everything and rejects
<mirror><id>all</id><mirrorOf>*</mirrorOf><url>https://mirror.example/repo</url></mirror>
# after: exempt the private repo
<mirror><id>all</id><mirrorOf>*,!corp-releases</mirrorOf><url>https://mirror.example/repo</url></mirror>
Defensive patterns

Strategy: retry

Validate before calling

// Verify reachability/credentials of a private repo before building
// curl -fsSL -u "$USER:$PASS" <repoUrl>/<knownPath> > /dev/null || fail "repo auth/broken"

Try / catch

try {
    retrieve(artifact, ...);
} catch (ArtifactMetadataRetrievalException e) {
    if (e.getCause() instanceof org.apache.maven.wagon.TransferFailedException) {
        // transient network/auth: back off and retry once, then surface cause
    }
}

Prevention

When it happens

Trigger: retrieve() fetches artifact X's POM; projectBuilder.build fails; the failure is classified as a transfer problem (HTTP 401/403/404-with-mirror-replay, connection refused, timeout, checksum mismatch) rather than a missing or malformed POM.

Common situations: Private repos requiring auth where credentials are missing in settings.xml; flaky networks/proxies interrupting POM download; Nexus/Artifactory returning 401 for unauthorized groups; snapshots where the POM was purged mid-transfer; mirrors (e.g. '*' mirrorOf to a repo lacking the artifact) causing download errors.

Related errors


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