{"record":{"id":"2a59f355674ad13a","repo":"elastic/elasticsearch","slug":"version-properties-resource-missing","errorCode":null,"errorMessage":"/version.properties resource missing","messagePattern":"/version\\.properties resource missing","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/VersionProperties.java","lineNumber":80,"sourceCode":"\n    static {\n        Properties props = getVersionProperties();\n        elasticsearch = props.getProperty(\"elasticsearch\");\n        lucene = props.getProperty(\"lucene\");\n        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":62,"sourceCodeEnd":94,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/VersionProperties.java#L62-L94","documentation":"VersionProperties's static initializer throws IllegalStateException (surfacing as ExceptionInInitializerError) when getResourceAsStream(\"/version.properties\") returns null. This file is a generated resource produced by the build (it carries the elasticsearch, lucene, bundled_jdk versions). Its absence means the build-tools JAR was built or assembled without running the version-properties generation step, so the class cannot initialize and the version constants are unavailable build-wide.","triggerScenarios":"Triggering the first access to any VersionProperties static member (getElasticsearch(), getLucene(), etc.) when /version.properties is not on the classpath. The static block runs once at class load; failure cascades as an ExceptionInInitializerError at the call site and NoClassDefFoundError on subsequent uses.","commonSituations":"Using a build-tools JAR built without the version generation task (incomplete publish, manual assembly, IDE with stale/missing resources); running build-tools tests against an exploded classpath missing the generated resources; a refactoring that moved or renamed version.properties; consuming build-tools as a dependency in a project that doesn't run the generate task.","solutions":["Rebuild build-tools via the normal Gradle build so /version.properties is generated into the resources output.","If consuming build-tools as a published dependency, ensure you depend on a properly published artifact (not a partial one).","In IDE, refresh the Gradle project and rebuild to regenerate resources; verify build-tools/build/resources/main/version.properties exists.","Check that no build logic strips or filters /version.properties during packaging."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (VersionProperties.class.getResourceAsStream(\"/version.properties\") == null) {\n    throw new IllegalStateException(\"/version.properties missing from classpath; rebuild build-tools\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always build build-tools via the normal Gradle build so /version.properties is generated.","Verify build-tools/build/resources/main/version.properties exists before consuming.","Depend only on properly published build-tools artifacts.","Refresh the Gradle project in IDE after build changes to regenerate resources."],"tags":["gradle","build-tools","version-properties","classpath","initialization"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}