Repository navigation
Description
Affected version
Maven 3.9.16 (but probably also 2.x resolver)
Bug description
I use multiple remote repositories.
Checking the highest version and then resolving (via API from https://github.com/bndtools/bnd/blob/0ca31d7acb96158049b56bc1749f4956ce5d1517/maven-plugins/bnd-baseline-maven-plugin/src/main/java/aQute/bnd/maven/baseline/plugin/BaselineMojo.java#L203) leads to the following logs
[INFO] Determining the baseline version for be.orbinson.aem:aem-dictionary-translator.core:jar:(,1.7.1-SNAPSHOT) using repositories [sonatype-central-portal (https://repo.maven.apache.org/maven2, default, releases+snapshots), central (https://repo.maven.apache.org/maven2, default, releases), nexus-netcentric (https://repo.int.netcentric.biz/nexus/content/groups/netcentric/, default, releases+snapshots)]
[INFO] Created Njord artifact store aem-dictionary-translator-00002 for remote repository sonatype-central-portal (https://repo.maven.apache.org/maven2, default, releases+snapshots)
INFO] Downloading from aem-dictionary-translator-00002: file:///Users/715508/.njord/aem-dictionary-translator-00002/be/orbinson/aem/aem-dictionary-translator.core/maven-metadata.xml
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/be/orbinson/aem/aem-dictionary-translator.core/maven-metadata.xml
[INFO] Downloading from nexus-netcentric: https://repo.int.netcentric.biz/nexus/content/groups/netcentric/be/orbinson/aem/aem-dictionary-translator.core/maven-metadata.xml
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/be/orbinson/aem/aem-dictionary-translator.core/maven-metadata.xml (1.2 kB at 5.8 kB/s)
[WARNING] Could not transfer metadata be.orbinson.aem:aem-dictionary-translator.core/maven-metadata.xml from/to nexus-netcentric (https://repo.int.netcentric.biz/nexus/content/groups/netcentric/): repo.int.netcentric.biz: nodename nor servname provided, or not known
[INFO] The baseline version was found to be 1.7.0
[INFO] Downloading from aem-dictionary-translator-00002: file:///Users/715508/.njord/aem-dictionary-translator-00002/be/orbinson/aem/aem-dictionary-translator.core/1.7.0/aem-dictionary-translator.core-1.7.0.jar
[INFO] Downloading from nexus-netcentric: https://repo.int.netcentric.biz/nexus/content/groups/netcentric/be/orbinson/aem/aem-dictionary-translator.core/1.7.0/aem-dictionary-translator.core-1.7.0.jar
...
[ERROR] Failed to execute goal biz.aQute.bnd:bnd-baseline-maven-plugin:7.4.0:baseline (baseline) on project ... Unable to locate a previous version of the artifact
This seems to be a race condition as depending on which remote repository responds first determines the outcome. Although the artifact is available on central (https://repo.maven.apache.org/maven2/be/orbinson/aem/aem-dictionary-translator.core/1.7.0/aem-dictionary-translator.core-1.7.0.jar) it is not in in nexus-netcentric. Resolving from the latter leads to a org.eclipse.aether.RepositoryException (wrapping a java.net.UnknownHostException).
The culprit is probably within
Line 220 in 54aa1d6
| public void get( |
Once a single thread hits an exception this leads to propagating the exception to the caller, without waiting for any of the other remote repos.
In my case the exception is a UnknownHostException (which is unfortunately swallowed in https://github.com/bndtools/bnd/blob/0ca31d7acb96158049b56bc1749f4956ce5d1517/maven-plugins/bnd-baseline-maven-plugin/src/main/java/aQute/bnd/maven/baseline/plugin/BaselineMojo.java#L137) and therefore not visible in the logs above.
I would argue the outcome should not depend on the fastest responding remote repo. If one fails with an exception the other remote repos should still be tried.
Activity
kwin commentedon Nov 28, 2026
According to GPT 6 Luna:
However I am wondering why the order for downloading metadata differs from the order for downloading artifacts and why the log still exposes multiple remote repos being requested in parallel...
cstamas commentedon Nov 28, 2026
This is a bit wrong: connector instances are created for one remote repository. Transporter instance is created by connector, hence are also per remote repository. So each connector "talks" to one remote repository via gotten transporter.
Hence, I don't understand "depending on which remote repository responds first determines the outcome" sentence, as connector talks to one single remote repository.
cstamas commentedon Nov 28, 2026
I don't think this is a race, and
BasicRepositoryConnector.getdoes not stop at the first failure. Each transfer's exception is caught inTaskRunner.run()and stored on that transfer, anderrorForwarder.await()waits for all tasks to finish. In any case, a connector only ever talks to one remote repository.What I think actually happens:
DefaultMetadataResolver, oneResolveTaskper repository). That's why the log shows three metadata requests at the same time, and why1.7.0is found incentral.ResolutionGroupwhen their URL, content type and repository-manager flag match. The repository ID is ignored:maven-resolver/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java
Lines 767 to 771 in 54aa1d6
sonatype-central-portalandcentralboth have the URLhttps://repo.maven.apache.org/maven2. Socentralis folded into the group ofsonatype-central-portal, which comes first in the list, and that group downloads throughsonatype-central-portal.sonatype-central-portaland serves it from its local store (file:///…/.njord/aem-dictionary-translator-00002). The jar is not in that store, so it's "not found".centralis never contacted for the jar, which matches the log: there is no "Downloading from central" line for the.jar.nexus-netcentric, which fails withUnknownHostException. The artifact ends up missing, andBaselineMojoswallows theRepositoryExceptionand reports "Unable to locate a previous version of the artifact".So this is an interaction between the resolver's grouping by URL and Njord. The grouping assumes that the same URL means the same content. Njord breaks that assumption by redirecting by repository ID while the URL stays the same. Without Njord, the merged group would fetch from the real Central and succeed.
To confirm: run the same build without Njord, or remove the duplicate
sonatype-central-portalentry from the repository list. The jar should then resolve fromcentral.Possible fixes:
central; orResolutionGroup.matches()also compares repository IDs, but that loses the dedupe this grouping exists for.kwin commentedon Nov 28, 2026
@cstamas Thanks a lot for those insights, however I am wondering why always the artifact is requested/downloaded from all group remote repos (in
maven-resolver/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java
Line 452 in 54aa1d6
This is a pretty bad edge case, because
bnd-resolver-maven-pluginincorrectly considers the distribution repository for resolving (bndtools/bnd#6945), thereforesonatype-central-portalends up in the remote repos in the first place. Looks like maveniverse/njord#214 should solve this.cstamas commentedon Nov 28, 2026
Why on earth bnd does this? I think same happens in CycloneDX...