apache/maven · critical · InitializationException

Unable to read Maven version from maven-core

Error message

Unable to read Maven version from maven-core

What it means

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.

Source

Thrown at compat/maven-compat/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java:54

@Singleton
public class DefaultRuntimeInformation implements RuntimeInformation, Initializable {

    @Inject
    private org.apache.maven.rtinfo.RuntimeInformation rtInfo;

    private ArtifactVersion applicationVersion;

    @Override
    public ArtifactVersion getApplicationVersion() {
        return applicationVersion;
    }

    @Override
    public void initialize() throws InitializationException {
        String mavenVersion = rtInfo.getMavenVersion();

        if (mavenVersion == null || mavenVersion.isEmpty()) {
            throw new InitializationException("Unable to read Maven version from maven-core");
        }

        applicationVersion = new DefaultArtifactVersion(mavenVersion);
    }
}

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Replace the Maven installation with a fresh official distribution and verify mvn -v prints a version
  2. 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
  3. In embedded setups, consume maven-core as the published artifact instead of a modified or shaded copy
  4. Rebuild the CI/Docker image from a clean base if the corruption came from image layering

Example fix

# before: broken distribution reports no version
mvn -v   # fails during startup with InitializationException
# after: replace installation wholesale and verify
tar -xzf apache-maven-3.9.x-bin.tar.gz -C /opt && export PATH=/opt/apache-maven-3.9.x/bin:$PATH
mvn -v
Defensive patterns

Strategy: try-catch

Validate before calling

// verify the version resource exists before bootstrapping Maven
try (java.io.InputStream in = org.apache.maven.rtinfo.RuntimeInformation.class
        .getClassLoader()
        .getResourceAsStream("META-INF/maven/org.apache.maven/maven-core/pom.properties")) {
    if (in == null) {
        // broken maven-core on the classpath: repair before starting
    }
}

Try / catch

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.

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/d50ef646bf5d2ea2. Report an issue: GitHub.