{"record":{"id":"eaa601b20e6ca683","repo":"elastic/elasticsearch","slug":"failed-to-load-version-properties","errorCode":null,"errorMessage":"Failed to load version properties","messagePattern":"Failed to load version properties","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/VersionProperties.java","lineNumber":85,"sourceCode":"        bundledJdkVendor = props.getProperty(\"bundled_jdk_vendor\");\n        bundledJdkVersion = props.getProperty(\"bundled_jdk\");\n        bundledJdkMajorVersion = bundledJdkVersion.split(\"[.+]\")[0];\n\n        for (String property : props.stringPropertyNames()) {\n            versions.put(property, props.getProperty(property));\n        }\n    }\n\n    private static Properties getVersionProperties() {\n        Properties props = new Properties();\n        InputStream propsStream = VersionProperties.class.getResourceAsStream(\"/version.properties\");\n        if (propsStream == null) {\n            throw new IllegalStateException(\"/version.properties resource missing\");\n        }\n        try {\n            props.load(propsStream);\n        } catch (IOException e) {\n            throw new IllegalStateException(\"Failed to load version properties\", e);\n        }\n        return props;\n    }\n\n    public static boolean isElasticsearchSnapshot() {\n        return elasticsearch.endsWith(\"-SNAPSHOT\");\n    }\n}\n","sourceCodeStart":67,"sourceCodeEnd":94,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/VersionProperties.java#L67-L94","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nProperties props = new Properties();\ntry {\n    props.load(propsStream);\n} catch (IOException e) {\n    throw new IllegalStateException(\"Failed to load version properties\", e);\n}\n\n// after (use the supported ext convention instead of the deprecated class)\n// in build.gradle:\n//   apply plugin: 'elasticsearch.version-properties'\n// then read versions via project.ext.versions / VersionPropertiesBuildService","handlingStrategy":"validation","validationCode":"// Validate the resource is loadable before any VersionProperties access\ntry (InputStream in = VersionProperties.class.getResourceAsStream(\"/version.properties\")) {\n    if (in == null) {\n        throw new IllegalStateException(\"version.properties not on classpath — rebuild build-tools\");\n    }\n    Properties p = new Properties();\n    p.load(in);\n    if (p.getProperty(\"elasticsearch\") == null) {\n        throw new IllegalStateException(\"version.properties missing 'elasticsearch' key\");\n    }\n} catch (IOException e) {\n    throw new IllegalStateException(\"version.properties unreadable\", e);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["build","initialization","resources","io","deprecated"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}