Introduction
Maven Resolver 2.x introduced prefix-file handling that can affect dependency resolution when an Artifactory Maven virtual repository is configured as a repository in the Maven project or settings. This can cause Maven builds to fail even though the artifacts are available.
Symptoms & error messages
This behavior may occur when utilizing Maven 3.10.x and Maven 4 clients that declare an Artifactory Maven virtual repository as a <repository> (e.g. a settings profile overriding central).
You may see an error similar to:
Path com/acme/internal/foo/1.0/foo-1.0.pom NOT allowed from <repoId>
You can confirm whether the virtual repository is serving a prefix file by running:
curl -i <ARTIFACTORY_URL>/artifactory/<VIRTUAL_REPO>/.meta/prefixes.txt
Cause
Maven Resolver 2.x uses .meta/prefixes.txt to determine which artifact paths are allowed from a repository. For a Maven virtual repository, Artifactory may return this file from one of its members, such as a remote repository proxying Maven Central. Since that file contains prefixes for that member only, Maven can incorrectly reject artifact paths that are available from other members of the virtual repository.
Step-by-step solution
Until the Artifactory fix is available, use one of the following workarounds.
Option 1: Modify the repository Excludes Pattern
This is the preferred workaround because it is applied on the Artifactory side and does not require changes to individual clients. The following configuration can be added either to the affected virtual repository or to each remote repository (of Maven Central / Apache) aggregated under it.
-
In Artifactory, open the configuration of the virtual repository or each remote Maven repository that is a member of the virtual repository.
-
Add the following pattern to the repository's Excludes Pattern:
.meta/**
-
Save the repository configuration.
This prevents .meta/prefixes.txt and its checksum files from being served by the remote repository. The virtual repository will therefore return 404 for the prefix file, causing Maven to continue without prefix filtering.
Normal artifact downloads are not affected.
Clients that have already downloaded the incorrect prefix file, Maven may continue using the cached copy until Resolver re-checks it (daily by default). To apply the change immediately, run:
mvn -U <your-existing-maven-command>
Option 2: Disable prefix-file resolution on the Maven client
Use this option when the Artifactory configuration cannot be changed.
To disable prefix-file resolution only for the affected Artifactory repository, add the following to .mvn/maven.config:
-Daether.remoteRepositoryFilter.prefixes.resolvePrefixFiles.<artifactoryRepoId>=false
Replace <artifactoryRepoId> with the Maven repository ID used for the Artifactory repository.
The same option can be configured organization-wide through MAVEN_ARGS or your CI configuration. As a broader alternative, prefix filtering can be disabled for all repositories:
-Daether.remoteRepositoryFilter.prefixes=false
The repository-specific option is recommended when possible because it limits the change to the affected repository.
Related external resources