elastic/elasticsearch · critical · IllegalStateException
Failed to load version properties
Error message
Failed to load version properties
What it means
Thrown inside the static initializer of the deprecated VersionProperties class when java.util.Properties.load fails reading the /version.properties classpath resource. It is a fatal initialization error: the original IOException is attached as the cause. Because it fires from a static block, it surfaces as ExceptionInInitializerError on first access to any VersionProperties field.
Source
Thrown at build-tools/src/main/java/org/elasticsearch/gradle/VersionProperties.java:85
bundledJdkVendor = props.getProperty("bundled_jdk_vendor");
bundledJdkVersion = props.getProperty("bundled_jdk");
bundledJdkMajorVersion = bundledJdkVersion.split("[.+]")[0];
for (String property : props.stringPropertyNames()) {
versions.put(property, props.getProperty(property));
}
}
private static Properties getVersionProperties() {
Properties props = new Properties();
InputStream propsStream = VersionProperties.class.getResourceAsStream("/version.properties");
if (propsStream == null) {
throw new IllegalStateException("/version.properties resource missing");
}
try {
props.load(propsStream);
} catch (IOException e) {
throw new IllegalStateException("Failed to load version properties", e);
}
return props;
}
public static boolean isElasticsearchSnapshot() {
return elasticsearch.endsWith("-SNAPSHOT");
}
}
View on GitHub (pinned to db6a809a66)
Solutions
- Run ./gradlew :build-tools:processResources (or the task that generates version.properties) to regenerate the resource, then rebuild.
- Inspect the packaged version.properties inside build-tools/build/libs/*.jar with `unzip -p <jar> version.properties` to confirm it is well-formed key=value text.
- Prefer the non-deprecated replacement (VersionPropertiesPlugin / VersionPropertiesBuildService per the Javadoc) instead of touching VersionProperties directly.
- If reading from a corrupt jar, rebuild the artifact: ./gradlew clean :build-tools:jar.
Example fix
// before
Properties props = new Properties();
try {
props.load(propsStream);
} catch (IOException e) {
throw new IllegalStateException("Failed to load version properties", e);
}
// after (use the supported ext convention instead of the deprecated class)
// in build.gradle:
// apply plugin: 'elasticsearch.version-properties'
// then read versions via project.ext.versions / VersionPropertiesBuildService Defensive patterns
Strategy: validation
Validate before calling
// Validate the resource is loadable before any VersionProperties access
try (InputStream in = VersionProperties.class.getResourceAsStream("/version.properties")) {
if (in == null) {
throw new IllegalStateException("version.properties not on classpath — rebuild build-tools");
}
Properties p = new Properties();
p.load(in);
if (p.getProperty("elasticsearch") == null) {
throw new IllegalStateException("version.properties missing 'elasticsearch' key");
}
} catch (IOException e) {
throw new IllegalStateException("version.properties unreadable", e);
} Prevention
- Avoid the deprecated VersionProperties class — use VersionPropertiesPlugin / VersionPropertiesBuildService per its Javadoc.
- Treat version.properties as generated: never edit it; regenerate via the build if it looks malformed.
- Add a CI sanity check that opens version.properties from the built jar and asserts key=value lines.
When it happens
Trigger: Triggered when Properties.load(propsStream) throws IOException on the resource stream returned by getResourceAsStream("/version.properties") (non-null, so the resource was found but unreadable). This occurs during class-loading of VersionProperties, i.e. on the first call to getElasticsearch(), getLucene(), getVersions(), etc.
Common situations: A corrupted/truncated version.properties in a built jar, an I/O fault reading from a packaged jar over a flaky filesystem, or a hand-modified build that left version.properties in an invalid state. Also seen when build-conventions preprocess resources and emits a malformed file.
Related errors
- Can't write resource `${resourcePath}` to ${destination}
- Failed to parse file {docFile}
- Failed to write marker file
- Failed to read OCI image layout index [{indexJson}]
- Error trying to read classpath resource: {}
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/eaa601b20e6ca683.
Report an issue: GitHub.