apache/maven · error · ArtifactResolverException

Unable to resolve artifacts:

Error message

Unable to resolve artifacts: 

What it means

DefaultArtifactResolver.resolve wraps resolution failures of one or more artifacts in ArtifactResolverException. When exactly one artifact was requested the message is that artifact's own error (usually 'could not be found' or a transfer failure); with multiple artifacts the message is prefixed 'Unable to resolve artifacts:' and the per-artifact errors are available through the attached ArtifactResolverResult (built from the BatchRequestException results).

Source

Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultArtifactResolver.java:131

                    List<ResolverResult> res = new ArrayList<>(resolverResults.size());
                    for (int i = 0; i < resolverResults.size(); i++) {
                        res.add(new ResolverResult(list.get(i), resolverResults.get(i)));
                    }
                    return res;
                } catch (ArtifactResolutionException e) {
                    throw new MavenExecutionException(e);
                }
            });

            return toResult(request, results.stream());
        } catch (BatchRequestException e) {
            String message;
            if (e.getResults().size() == 1) {
                message = e.getResults().iterator().next().error().getMessage();
            } else {
                message = "Unable to resolve artifacts: " + e.getMessage();
            }
            throw new ArtifactResolverException(message, e, toResult(request, e));
        } finally {
            RequestTraceHelper.exit(trace);
        }
    }

    ArtifactResolverResult toResult(ArtifactResolverRequest request, BatchRequestException exception) {
        return toResult(
                request,
                exception.getResults().stream()
                        .map(rr -> {
                            if (rr.result() != null) {
                                return rr.result();
                            } else if (rr.error() != null) {
                                return new ResolverResult(null, ((ArtifactResolutionException) rr.error()).getResult());
                            } else {
                                throw new IllegalStateException("Unexpected result: " + rr);
                            }
                        })

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Read the per-artifact errors from the ArtifactResolverResult attached to the exception to see which coordinates failed and why
  2. Fix the coordinates or add the missing repository to the session/request repositories
  3. Check settings.xml mirrors/proxies and network access to the repository URLs; if a pull was rejected earlier, clear stale .lastUpdated markers in the local repo (or run with -U equivalent)
  4. For authenticated repos, add matching <server> credentials in settings.xml

Example fix

// before
ArtifactResolverResult r = session.getService(ArtifactResolver.class).resolve(request);

// after
try {
    ArtifactResolverResult r = session.getService(ArtifactResolver.class).resolve(request);
} catch (ArtifactResolverException e) {
    e.getResult().artifacts().forEach(a -> log.error('resolved: ' + a));
    throw e;
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    ArtifactResolverResult result = session.getService(ArtifactResolver.class).resolve(request);
} catch (ArtifactResolverException e) {
    // single artifact: e.getMessage() is the per-artifact error
    // multiple: inspect e.getResult() for per-artifact outcomes, then report coordinates + cause
}

Prevention

When it happens

Trigger: session.getService(ArtifactResolver.class).resolve(ArtifactResolverRequest with one or more ProducedArtifact/coordinates) where at least one artifact is missing from all configured repositories, unreachable, or its checksum/validation fails. For a single artifact the first result's error message is surfaced verbatim.

Common situations: Dependency not in central nor in configured private repos (typo in groupId/artifactId/version); offline mode or VPN/proxy blocking the repo; 401 on authenticated pulls; version exists only in a repository not listed; local repository cache corrupted (.lastUpdated files blocking re-attempt).

Related errors


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