{"record":{"id":"d50ef646bf5d2ea2","repo":"apache/maven","slug":"unable-to-read-maven-version-from-maven-core","errorCode":null,"errorMessage":"Unable to read Maven version from maven-core","messagePattern":"Unable to read Maven version from maven-core","errorType":"exception","errorClass":"InitializationException","httpStatus":null,"severity":"critical","filePath":"compat/maven-compat/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java","lineNumber":54,"sourceCode":"@Singleton\npublic class DefaultRuntimeInformation implements RuntimeInformation, Initializable {\n\n    @Inject\n    private org.apache.maven.rtinfo.RuntimeInformation rtInfo;\n\n    private ArtifactVersion applicationVersion;\n\n    @Override\n    public ArtifactVersion getApplicationVersion() {\n        return applicationVersion;\n    }\n\n    @Override\n    public void initialize() throws InitializationException {\n        String mavenVersion = rtInfo.getMavenVersion();\n\n        if (mavenVersion == null || mavenVersion.isEmpty()) {\n            throw new InitializationException(\"Unable to read Maven version from maven-core\");\n        }\n\n        applicationVersion = new DefaultArtifactVersion(mavenVersion);\n    }\n}\n","sourceCodeStart":36,"sourceCodeEnd":60,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-compat/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java#L36-L60","documentation":"DefaultRuntimeInformation.initialize() takes the version string from RuntimeInformation (parsed from maven-core's own resources) and turns it into the application version exposed to plugins. If that string is null or empty, initialization fails with InitializationException - Maven literally could not determine its own version. This points at a damaged, repackaged, or non-standard Maven installation rather than any project setting.","triggerScenarios":"Booting a Maven distribution whose maven-core jar is missing its version resources (shaded, repackaged, or truncated download), or a custom launcher/embedded classpath that supplies maven-core classes without the META-INF properties that carry the version.","commonSituations":"Hand-patched or shaded maven-core jars; partial Maven upgrades mixing lib jars; IDE-bundled Maven broken by an IDE update; Docker images built by copying a half-extracted archive.","solutions":["Replace the Maven installation with a fresh official distribution and verify mvn -v prints a version","Inspect the maven-core jar: unzip -l $MAVEN_HOME/lib/maven-core-*.jar | grep pom.properties - it must contain META-INF/maven/org.apache.maven/maven-core/pom.properties; if not, it was repackaged, so restore the original jar","In embedded setups, consume maven-core as the published artifact instead of a modified or shaded copy","Rebuild the CI/Docker image from a clean base if the corruption came from image layering"],"exampleFix":"# before: broken distribution reports no version\nmvn -v   # fails during startup with InitializationException\n# after: replace installation wholesale and verify\ntar -xzf apache-maven-3.9.x-bin.tar.gz -C /opt && export PATH=/opt/apache-maven-3.9.x/bin:$PATH\nmvn -v","handlingStrategy":"try-catch","validationCode":"// verify the version resource exists before bootstrapping Maven\ntry (java.io.InputStream in = org.apache.maven.rtinfo.RuntimeInformation.class\n        .getClassLoader()\n        .getResourceAsStream(\"META-INF/maven/org.apache.maven/maven-core/pom.properties\")) {\n    if (in == null) {\n        // broken maven-core on the classpath: repair before starting\n    }\n}","typeGuard":null,"tryCatchPattern":"Catch InitializationException from the container initialize phase; if the message is 'Unable to read Maven version from maven-core', abort and repair the distribution - retrying against the same installation reproduces the failure.","preventionTips":["Install Maven from official distributions; never hand-patch jars under MAVEN_HOME/lib.","Pin the Maven distribution URL/version in CI images for reproducibility.","Add a mvn -v smoke test to Dockerfiles immediately after installing Maven."],"tags":["maven","installation","version","bootstrap","initialization"],"backgroundTag":"maven-version-detection-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}