elastic/elasticsearch · critical · IllegalStateException

/version.properties resource missing

Error message

/version.properties resource missing

What it means

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.

Source

Thrown at build-tools/src/main/java/org/elasticsearch/gradle/VersionProperties.java:80

    static {
        Properties props = getVersionProperties();
        elasticsearch = props.getProperty("elasticsearch");
        lucene = props.getProperty("lucene");
        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

  1. Rebuild build-tools via the normal Gradle build so /version.properties is generated into the resources output.
  2. If consuming build-tools as a published dependency, ensure you depend on a properly published artifact (not a partial one).
  3. In IDE, refresh the Gradle project and rebuild to regenerate resources; verify build-tools/build/resources/main/version.properties exists.
  4. Check that no build logic strips or filters /version.properties during packaging.
Defensive patterns

Strategy: validation

Validate before calling

if (VersionProperties.class.getResourceAsStream("/version.properties") == null) {
    throw new IllegalStateException("/version.properties missing from classpath; rebuild build-tools");
}

Prevention

When it happens

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

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

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/2a59f355674ad13a. Report an issue: GitHub.