{"record":{"id":"d39e55e8125a9c94","repo":"apache/maven","slug":"unable-to-get-a-selected-version-for","errorCode":null,"errorMessage":"Unable to get a selected Version for {}","messagePattern":"Unable to get a selected Version for (.+?)","errorType":"exception","errorClass":"OverConstrainedVersionException","httpStatus":null,"severity":"error","filePath":"compat/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java","lineNumber":133,"sourceCode":"\n        return ret;\n    }\n\n    private List<Artifact> getTrail() throws OverConstrainedVersionException {\n        if (trail == null) {\n            List<Artifact> ids = new LinkedList<>();\n            ResolutionNode node = this;\n            while (node != null) {\n                Artifact artifact = node.getArtifact();\n                if (artifact.getVersion() == null) {\n                    // set the recommended version\n                    ArtifactVersion selected = artifact.getSelectedVersion();\n                    // MNG-2123: null is a valid response to getSelectedVersion, don't\n                    // assume it won't ever be.\n                    if (selected != null) {\n                        artifact.selectVersion(selected.toString());\n                    } else {\n                        throw new OverConstrainedVersionException(\n                                \"Unable to get a selected Version for \" + artifact.getArtifactId(), artifact);\n                    }\n                }\n\n                ids.add(0, artifact);\n                node = node.parent;\n            }\n            trail = ids;\n        }\n        return trail;\n    }\n\n    public boolean isResolved() {\n        return children != null;\n    }\n\n    /**\n     * Test whether the node is direct or transitive dependency.","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java#L115-L151","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"<!-- before: transitive ranges [1.0,1.5) + [2.0,) intersect to nothing -->\n<!-- after: dependencyManagement pins a concrete version -->\n<dependencyManagement>\n  <dependencies>\n    <dependency>\n      <groupId>com.example</groupId>\n      <artifactId>lib</artifactId>\n      <version>2.1.0</version>\n    </dependency>\n  </dependencies>\n</dependencyManagement>","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"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.","preventionTips":["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."],"tags":["maven","version-range","conflict","resolution","dependency-management"],"backgroundTag":"unresolvable-version-range","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}