elastic/elasticsearch · error · IllegalArgumentException

bundledJdk cannot be set on elasticsearch distribution [${na

Error message

bundledJdk cannot be set on elasticsearch distribution [${name}] of type [docker]

What it means

Thrown by ElasticsearchDistribution.finalizeValues() when a DOCKER-type distribution has its `bundledJdk` property explicitly set. Docker images ship with a JDK baked into the image layer, so toggling bundledJdk has no effect and the option is forbidden to prevent silent misconfiguration. Only archive/rpm/deb distributions honor bundledJdk (and default it to true).

Source

Thrown at build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java:263

            throw new IllegalArgumentException(
                "failIfUnavailable cannot be 'false' on elasticsearch distribution [" + name + "] of type [" + getType() + "]"
            );
        }

        if (getType() == ElasticsearchDistributionTypes.ARCHIVE) {
            // defaults for archive, set here instead of via convention so integ-test-zip can verify they are not set
            if (platform.isPresent() == false) {
                platform.set(CURRENT_PLATFORM);
            }
        } else { // rpm, deb or docker
            if (platform.isPresent()) {
                throw new IllegalArgumentException(
                    "platform cannot be set on elasticsearch distribution [" + name + "] of type [" + getType() + "]"
                );
            }
            if (isDocker()) {
                if (bundledJdk.isPresent()) {
                    throw new IllegalArgumentException(
                        "bundledJdk cannot be set on elasticsearch distribution [" + name + "] of type " + "[docker]"
                    );
                }
            }
        }

        if (bundledJdk.isPresent() == false) {
            bundledJdk.set(true);
        }

        version.finalizeValue();
        platform.finalizeValue();
        type.finalizeValue();
        bundledJdk.finalizeValue();
    }
}

View on GitHub (pinned to db6a809a66)

Solutions

  1. Remove the setBundledJdk(...) call from the docker distribution configuration.
  2. If you need a different JDK in docker, build a custom image rather than toggling bundledJdk.
  3. Reserve bundledJdk configuration for archive/rpm/deb distributions only.

Example fix

// before
distributions {
  docker {
    bundledJdk = false // throws: docker always bundles its own JDK
  }
}
// after
distributions {
  docker {
    // bundledJdk left unset; image JDK is used
  }
}
Defensive patterns

Strategy: validation

Validate before calling

ElasticsearchDistribution dist = ...;
if (dist.isDocker()) {
    assert dist.getBundledJdk() == null : "bundledJdk must not be set on docker distribution " + dist.getName();
}

Prevention

When it happens

Trigger: Calling setBundledJdk(...) on an ElasticsearchDistribution whose isDocker() is true, then triggering finalizeValues(). The check fires inside the `else` branch (non-archive) under `if (isDocker())`.

Common situations: Carrying over a bundledJdk=false setting (common for slim archive dists) when switching a distribution to docker; assuming bundledJdk is uniformly configurable across all distribution types.

Related errors


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