apache/maven · error · ArtifactDeployerException

Unable to deploy artifacts

Error message

Unable to deploy artifacts

What it means

DefaultArtifactDeployer.deploy wraps the Eclipse Resolver's DeploymentException in ArtifactDeployerException('Unable to deploy artifacts') whenever publishing produced artifacts to a remote repository fails at the transport or protocol level. The original exception (HTTP status, transfer error, deployment rules rejection) is attached as the cause, so the real reason must be read from getCause().

Source

Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultArtifactDeployer.java:56

 */
@Named
@Singleton
public class DefaultArtifactDeployer implements ArtifactDeployer {

    @Override
    public void deploy(@Nonnull ArtifactDeployerRequest request) {
        requireNonNull(request, "request");
        InternalSession session = InternalSession.from(request.getSession());
        Collection<ProducedArtifact> artifacts = requireNonNull(request.getArtifacts(), "request.artifacts");
        RemoteRepository repository = requireNonNull(request.getRepository(), "request.repository");
        try {
            DeployRequest deployRequest = new DeployRequest()
                    .setRepository(session.toRepository(repository))
                    .setArtifacts(session.toArtifacts(artifacts));

            session.getRepositorySystem().deploy(session.getSession(), deployRequest);
        } catch (DeploymentException e) {
            throw new ArtifactDeployerException("Unable to deploy artifacts", e);
        }
    }
}

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Inspect exception.getCause() (and its message/HTTP status) to identify the server-side rejection
  2. Verify credentials: settings.xml <server><id> must match the distributionManagement repository id, and the user must have deploy rights
  3. Check the distributionManagement URL points to the correct deploy endpoint (e.g. .../repository/maven-releases vs maven-snapshots) for the artifact's version
  4. If redeploying, enable redeployment on the repository or bump the version, since most release repos reject overwrite

Example fix

// before
session.getService(ArtifactDeployer.class).deploy(request);

// after
try {
    session.getService(ArtifactDeployer.class).deploy(request);
} catch (ArtifactDeployerException e) {
    throw new IllegalStateException('Deploy failed: ' + e.getCause().getMessage(), e);
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    session.getService(ArtifactDeployer.class).deploy(request);
} catch (ArtifactDeployerException e) {
    Throwable cause = e.getCause();
    // log cause.getMessage() (HTTP status / server rejection) and fail the deploy step
    throw e;
}

Prevention

When it happens

Trigger: session.getService(ArtifactDeployer.class).deploy(new ArtifactDeployerRequest(session, repository, artifacts)) where the deployment fails: 401/403 from the server, wrong repository URL, missing deployment rights, snapshot-to-release mismatch, or a file transfer error.

Common situations: distributionManagement url typo or pointing to a repo the user cannot write to; credentials not configured in settings.xml <server> with the repository id; trying to deploy a release artifact to a snapshot repository (or vice versa); OSSRH / Nexus / Artifactory rejecting redeployment of an existing artifact; proxy or TLS issues between the build and the server.

Related errors


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