apache/maven · warning
Could not locate META-INF/maven/org.apache.maven/maven-core/
Error message
Could not locate META-INF/maven/org.apache.maven/maven-core/pom.properties on classpath, Maven runtime information not available
What it means
DefaultRuntimeInformation.loadMavenVersion() tried to open /META-INF/maven/org.apache.maven/maven-core/pom.properties from the classloader to read the running Maven version and getResourceAsStream returned null. The version ends up as an empty string, so RuntimeInformation.getMavenVersion() reports nothing and features that depend on it (e.g. enforcer's requireMavenVersion, maven-war/enforcer plugin metadata checks) degrade. The resource is generated by the maven-core build itself; it is present in every official distribution jar.
Source
Thrown at impl/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java:70
this.versionScheme = versionScheme;
this.mavenVersion = loadMavenVersion();
}
@Override
public String getMavenVersion() {
return mavenVersion;
}
private String loadMavenVersion() {
Properties props = new Properties();
String resource = "META-INF/maven/org.apache.maven/maven-core/pom.properties";
try (InputStream is = DefaultRuntimeInformation.class.getResourceAsStream("/" + resource)) {
if (is != null) {
props.load(is);
} else {
logger.warn("Could not locate " + resource + " on classpath, Maven runtime information not available");
}
} catch (IOException e) {
String msg = "Could not parse " + resource + ", Maven runtime information not available";
if (logger.isDebugEnabled()) {
logger.warn(msg, e);
} else {
logger.warn(msg);
}
}
String version = props.getProperty("version", "").trim();
if (!version.startsWith("${")) {
return version;
} else {
return "";
}
}View on GitHub (pinned to e4093d4e12)
Solutions
- Run builds with an official Maven distribution (apache-maven-x.y.z-bin.tar.gz) so maven-core ships its pom.properties
- If shading/embedding, keep META-INF/maven/** resources: configure the shade/assembly filter to include them
- Verify the jar is intact: unzip -l $M2_HOME/lib/maven-core-*.jar | grep pom.properties
- In embedding code, do not depend on getMavenVersion() when it returns empty; fall back to a version you inject yourself
Example fix
<!-- before: shade filter strips META-INF and drops pom.properties -->
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
</filters>
</configuration>
</plugin>
<!-- after: keep maven metadata, only strip signatures -->
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</plugin> Defensive patterns
Strategy: fallback
Validate before calling
// Embedding Maven: verify runtime info is available before relying on it
try (var is = DefaultRuntimeInformation.class
.getResourceAsStream("/META-INF/maven/org.apache.maven/maven-core/pom.properties")) {
if (is == null) {
log.warn("maven-core metadata missing on classpath; falling back to injected version");
}
}
// or simply probe the API:
String v = runtimeInformation.getMavenVersion();
if (v == null || v.isBlank()) v = System.getProperty("maven.version.default", "unknown"); Prevention
- Launch Maven from official distributions instead of hand-assembled classpaths
- When shading or embedding maven-core, keep META-INF/maven/** in the filter configuration
- Never parse getMavenVersion() blindly; check for empty string and degrade gracefully
- Verify distribution integrity with checksums after download
When it happens
Trigger: Loading DefaultRuntimeInformation in a classloader that cannot see the maven-core jar's META-INF metadata: embedding Maven inside an application with an isolated/child-first classloader, a shaded or repackaged uber-jar that dropped META-INF/maven entries, or a hand-rolled Maven classpath assembled from loose classes.
Common situations: Custom launcher scripts that build the Maven classpath manually and exclude pom.properties; fat-jar bundling of maven-core with an aggressive META-INF filter; OSGi or container classloaders that hide META-INF/maven; corrupted maven-core jar in a partial download.
Related errors
- The version cannot be empty.
- Unable to lookup org.eclipse.aether.RepositorySystem
- %nThere can only be one user supplied ConfigurationProcessor
- Not yet implemented
- A required class was missing while executing {}: {}
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/bf8764dba0776942.
Report an issue: GitHub.