apache/maven · error · OverConstrainedVersionException
Unable to get a selected Version for {}
Error message
Unable to get a selected Version for {} What it means
While materializing the dependency trail, ResolutionNode must fix a concrete version for artifacts declared with a version range; if artifact.getSelectedVersion() returns null - null being a legitimate answer per MNG-2123 - it throws OverConstrainedVersionException naming the artifactId. It means the accumulated version constraints have an empty intersection (or match no available version), i.e. the artifact is over-constrained, not merely in soft conflict.
Source
Thrown at compat/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java:133
return ret;
}
private List<Artifact> getTrail() throws OverConstrainedVersionException {
if (trail == null) {
List<Artifact> ids = new LinkedList<>();
ResolutionNode node = this;
while (node != null) {
Artifact artifact = node.getArtifact();
if (artifact.getVersion() == null) {
// set the recommended version
ArtifactVersion selected = artifact.getSelectedVersion();
// MNG-2123: null is a valid response to getSelectedVersion, don't
// assume it won't ever be.
if (selected != null) {
artifact.selectVersion(selected.toString());
} else {
throw new OverConstrainedVersionException(
"Unable to get a selected Version for " + artifact.getArtifactId(), artifact);
}
}
ids.add(0, artifact);
node = node.parent;
}
trail = ids;
}
return trail;
}
public boolean isResolved() {
return children != null;
}
/**
* Test whether the node is direct or transitive dependency.View on GitHub (pinned to e4093d4e12)
Solutions
- Run mvn dependency:tree -Dverbose to find the artifact and the competing constraints
- Pin the artifact with an explicit version in <dependencyManagement> (or a direct dependency) instead of letting the ranges intersect
- Fix or widen the range in the offending POM so the intersection is non-empty
- Make sure a version satisfying the range is reachable: check the repository contents, or publish/proxy the missing version internally
Example fix
<!-- before: transitive ranges [1.0,1.5) + [2.0,) intersect to nothing -->
<!-- after: dependencyManagement pins a concrete version -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>lib</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>
</dependencyManagement> Defensive patterns
Strategy: try-catch
Try / catch
Catch OverConstrainedVersionException; use getArtifact() to see which artifactId has no selectable version, then pin it in dependencyManagement - a retry without changing constraints will fail identically.
Prevention
- Avoid version ranges in published POMs; publish with concrete versions.
- Use dependencyManagement to make transitive ranges deterministic.
- After dependency upgrades, run dependency:tree -Dverbose to catch emptied intersections early.
When it happens
Trigger: Resolving a dependency declared with a version range (e.g. [1.0,2.0)) whose acceptable set becomes empty after merging constraints arriving from multiple paths in the graph, or whose range excludes every version actually published in the reachable repositories.
Common situations: Two transitive ranges like [1.0,1.5) and [2.0,) meeting on the same artifact; a range [1.4,1.5) when only 1.6 exists in the repositories; Maven-2-era POMs using ranges against modern repository layouts.
Related errors
- Invalid version for dependency " + dependency.getManagementK
- No versions matched the requested parent version range '%s'
- A dependency has introduced a cycle
- Invalid JDK version in profile '{}': {}
- Failed to process POM for " + artifact.getId() + ": " + miss
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/d39e55e8125a9c94.
Report an issue: GitHub.