apache/maven · error · OverConstrainedVersionException
Unable to find a version in " + resetArtifact.getAvailableVe
Error message
Unable to find a version in " + resetArtifact.getAvailableVersions() + " to match the range " + resetArtifact.getVersionRange()
What it means
After the legacy resolver re-reads available versions for a ranged dependency during conflict resolution (the 'reset artifact' path), it calls VersionRange.matchVersion(availableVersions). If no listed version satisfies the range, matchVersion returns null (MNG-2861) and this OverConstrainedVersionException is thrown, naming both the available version list and the range. It means metadata was fetched successfully — the versions simply do not intersect the constraint.
Source
Thrown at compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java:322
resetArtifact.setDependencyTrail(node.getDependencyTrail());
throw new ArtifactResolutionException(
"Unable to get dependency information: " + e.getMessage(),
resetArtifact,
request.getRemoteRepositories(),
e);
}
}
// end hack
// MNG-2861: match version can return null
ArtifactVersion selectedVersion = resetArtifact
.getVersionRange()
.matchVersion(resetArtifact.getAvailableVersions());
if (selectedVersion != null) {
resetArtifact.selectVersion(selectedVersion.toString());
} else {
throw new OverConstrainedVersionException(
"Unable to find a version in " + resetArtifact.getAvailableVersions()
+ " to match the range " + resetArtifact.getVersionRange(),
resetArtifact);
}
fireEvent(ResolutionListener.SELECT_VERSION_FROM_RANGE, listeners, resetNodes[j]);
}
}
}
// Conflict Resolution
ResolutionNode resolved = null;
for (Iterator<ConflictResolver> j = conflictResolvers.iterator();
resolved == null && j.hasNext(); ) {
ConflictResolver conflictResolver = j.next();
resolved = conflictResolver.resolveConflict(previous, node);
}View on GitHub (pinned to e4093d4e12)
Solutions
- Read the message: it lists the available versions — pick one and pin it as a concrete <version> instead of the range
- Widen or correct the range so it includes at least one of the listed versions (check for wrong upper bound or wrong groupId/artifactId)
- If a newer version exists upstream but is not listed, refresh metadata with mvn -U and verify the repository/mirror actually proxies it
- In multi-module builds, use dependencyManagement to pin the conflicting transitive dependency to a version that exists
Example fix
<!-- before: repo only has 1.3.0 and 1.4.1 --> <version>[1.2,1.3)</version> <!-- after --> <version>[1.2,1.5)</version> <!-- or simply --> <version>1.4.1</version>
Defensive patterns
Strategy: validation
Validate before calling
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.artifact.versioning.ArtifactVersion;
boolean rangeSatisfiable(VersionRange range, List<ArtifactVersion> available) {
return range.matchVersion(available) != null; // exactly the check that throws otherwise
}
if (!rangeSatisfiable(artifact.getVersionRange(), artifact.getAvailableVersions())) {
throw new IllegalStateException("Range " + artifact.getVersionRange()
+ " matches none of " + artifact.getAvailableVersions());
} Try / catch
try {
collector.collect(artifacts, ...);
} catch (OverConstrainedVersionException e) {
// message contains available versions + range; surface both to the user
report("Version range conflict for " + e.getArtifact()?.getId()
+ ": " + e.getMessage() + " — pin a listed version or widen the range");
} Prevention
- Avoid version ranges in releases; pin versions via dependencyManagement
- When ranges are necessary, prefer soft ranges [1.2,) over fully-bounded ones so newer releases satisfy them
- Run dependency:analyze / versions:display-dependency-updates in CI to notice when published versions drift outside your ranges
When it happens
Trigger: A dependency version range that excludes every version actually present in reachable repositories, hit on the conflict-resolution/re-resolution branch of DefaultLegacyArtifactCollector — e.g. range [1.2,1.3) when the repository only contains 1.3.0 and 1.4.1, or a range requiring 2.x when only 1.x was ever published.
Common situations: Upper-bound typo ([1.0,1.5) when 1.5.0 is the only release); a range written against a library whose maintainers never published a version inside it; another dependency forcing re-resolution of an already-ranged artifact; local repo containing only stale versions while newer ones exist but are unreachable.
Related errors
- Unable to get dependency information: " + e.getMessage()
- No versions are present in the repository for the artifact w
- Couldn't find a version in " + versions + " to match range "
- Unable to get dependency information for " + artifact.getId(
- Cannot find conflict resolver of type: " + type
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/1fb68b1a0251ed4c.
Report an issue: GitHub.