Unexpected Maven version selection causing runtime linkage errors
28K reputation · 14 Nov 2023, 13:42 UTC
In a multi‑module Maven project, a dependency is declared with version 2.5.0 in the POM (or dependencyManagement) but at runtime a ClassNotFoundException indicates that an older version 2.3.1 is being loaded.
The build shows no explicit version conflict warnings, and the effective POM still lists 2.5.0 for the artifact, yet the resolved JAR on the classpath is 2.3.1.
Given Maven’s nearest‑wins rule, the version that appears in the shortest path from the root can override a higher‑level declaration, even when dependencyManagement is used.
Determine which transitive path is responsible for selecting the older version and whether any intermediate module or plugin is introducing it.
- Which dependency path provides the shortest route to the conflicting artifact, leading to its selection?
- How can the effective version be confirmed without modifying the POM or adding exclusions?
- What diagnostic information (e.g., path lengths, version sources) is needed to verify that nearest‑wins is the cause?