Loading

Mule Maven Build Fails With Could Not Transfer Artifact

Udgivelsesdato: Oct 21, 2026
Beskrivelse

You build a Mule project with Maven, and the build fails because a dependency can't be downloaded. The error names a remote repository and an HTTP status, for example:

[ERROR] Failed to execute goal on project PROJECT_NAME: Could not resolve dependencies for project com.mycompany:project_name:mule:1.0.0: Failed to collect dependencies at your.package:artifact:jar:1.0.0: Failed to read artifact descriptor for your.package:artifact:jar:1.0.0: Could not transfer artifact your.package:artifact:pom:1.0.0 from/to releases-ee (https://repository.mulesoft.org/nexus/content/repositories/releases-ee/): Not authorized , ReasonPhrase:Unauthorized. -> [Help 1]

Maven looks for each dependency in the local repository (~/.m2/repository) first, and then in the remote repositories that the project object model (POM) and the active profiles in settings.xml define. The Maven guide to multiple repositories states that remote repositories are "queried in the following order for artifacts until one returns a valid result".

The repository named in the error isn't necessarily the one that hosts the artifact. When none of the repositories Maven can read returns the artifact, the error can name another repository that Maven tried. For example, a custom asset published to Anypoint Exchange can fail with an error for the MuleSoft Enterprise repository releases-ee. A Not authorized (401) status means that the repository refused the credentials Maven sent, or that Maven sent no credentials for it.

Løsning

To fix the error, find the repository that hosts the artifact, and make sure Maven can reach that repository with valid credentials.

Step 1. Check which repositories Maven uses

These commands print the settings and the POM that Maven actually uses, after profiles and parent POMs are applied:

mvn help:effective-settings > mvn-settings.txt
mvn help:effective-pom -Dverbose > mvn-pom.txt

In the output, find the repository that hosts the artifact. Check its url, and check that settings.xml has a <server> entry whose <id> matches the repository <id>. Maven sends credentials to a repository only through a server entry with the same id.

In a continuous integration (CI) pipeline, the build uses the settings.xml of the build agent, not your local one. If the file isn't in the default location, pass it with mvn -s <path-to-settings.xml>.

Step 2. Check the credentials for Anypoint Exchange

If the artifact is a custom asset published to Anypoint Exchange, such as a custom connector or a custom policy, the project needs the Exchange Maven repository. This repository entry in the POM uses the US control plane:

<repository>
  <id>anypoint-exchange</id>
  <name>Anypoint Exchange</name>
  <url>https://maven.anypoint.mulesoft.com/api/v3/maven</url>
  <layout>default</layout>
</repository>

For the EU control plane, the URL is https://maven.eu1.anypoint.mulesoft.com/api/v3/maven. For Gov Cloud, it is https://maven.gov.anypoint.mulesoft.com/api/v2/maven.

The matching server entry in settings.xml holds the credentials. This example uses a connected app; keep ~~~Client~~~ as the username:

<server>
  <id>anypoint-exchange</id>
  <username>~~~Client~~~</username>
  <password><client_id>~?~<client_secret></password>
</server>

The connected app or user must have access to the asset in Exchange. For the username and password and token forms, see Publishing Assets Using Maven.

Step 3. Check the credentials for the MuleSoft Enterprise repository

If the artifact is a MuleSoft Enterprise artifact, the project needs the MuleSoft Enterprise repository https://repository.mulesoft.org/nexus-ee/content/repositories/releases-ee/ and a server entry with Nexus enterprise credentials. To get the credentials, open a Support case. For the configuration, see Maven Reference and MuleSoft Anypoint Studio Maven Build Fails: Could not resolve dependencies or Failed to collect dependencies.

Step 4. Find which dependency requests the artifact

If the error persists, these commands show which dependency brings in the artifact and each repository request Maven makes:

mvn dependency:tree -Dverbose > mvn-tree.txt
mvn clean package -X -e > mvn-debug.txt

The -X option writes debug output, and -e writes the full error stack. Remove passwords and tokens from these files before you attach them to a Support case.

Alternative: install the artifact in the local repository

If you have the artifact file and can't get access to the repository that hosts it, you can install the file in the local repository of the machine that runs the build:

mvn install:install-file -Dfile=<path-to-artifact.jar> -DpomFile=<path-to-pom.xml>

This fixes the build only on that machine, so prefer fixing the repository configuration.

Yderligere ressourcer

Maven Support In Mule

Vidensartikelnummer

001118073

 
Indlæser
Salesforce Help | Article