{"record":{"id":"accc37927f9c9eaa","repo":"elastic/elasticsearch","slug":"bundledjdk-cannot-be-set-on-elasticsearch-distribu-accc37","errorCode":null,"errorMessage":"bundledJdk cannot be set on elasticsearch distribution [${name}] of type [docker]","messagePattern":"bundledJdk cannot be set on elasticsearch distribution \\[(.+?)\\] of type \\[docker\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java","lineNumber":263,"sourceCode":"            throw new IllegalArgumentException(\n                \"failIfUnavailable cannot be 'false' on elasticsearch distribution [\" + name + \"] of type [\" + getType() + \"]\"\n            );\n        }\n\n        if (getType() == ElasticsearchDistributionTypes.ARCHIVE) {\n            // defaults for archive, set here instead of via convention so integ-test-zip can verify they are not set\n            if (platform.isPresent() == false) {\n                platform.set(CURRENT_PLATFORM);\n            }\n        } else { // rpm, deb or docker\n            if (platform.isPresent()) {\n                throw new IllegalArgumentException(\n                    \"platform cannot be set on elasticsearch distribution [\" + name + \"] of type [\" + getType() + \"]\"\n                );\n            }\n            if (isDocker()) {\n                if (bundledJdk.isPresent()) {\n                    throw new IllegalArgumentException(\n                        \"bundledJdk cannot be set on elasticsearch distribution [\" + name + \"] of type \" + \"[docker]\"\n                    );\n                }\n            }\n        }\n\n        if (bundledJdk.isPresent() == false) {\n            bundledJdk.set(true);\n        }\n\n        version.finalizeValue();\n        platform.finalizeValue();\n        type.finalizeValue();\n        bundledJdk.finalizeValue();\n    }\n}\n","sourceCodeStart":245,"sourceCodeEnd":280,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java#L245-L280","documentation":"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).","triggerScenarios":"Calling setBundledJdk(...) on an ElasticsearchDistribution whose isDocker() is true, then triggering finalizeValues(). The check fires inside the `else` branch (non-archive) under `if (isDocker())`.","commonSituations":"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.","solutions":["Remove the setBundledJdk(...) call from the docker distribution configuration.","If you need a different JDK in docker, build a custom image rather than toggling bundledJdk.","Reserve bundledJdk configuration for archive/rpm/deb distributions only."],"exampleFix":"// before\ndistributions {\n  docker {\n    bundledJdk = false // throws: docker always bundles its own JDK\n  }\n}\n// after\ndistributions {\n  docker {\n    // bundledJdk left unset; image JDK is used\n  }\n}","handlingStrategy":"validation","validationCode":"ElasticsearchDistribution dist = ...;\nif (dist.isDocker()) {\n    assert dist.getBundledJdk() == null : \"bundledJdk must not be set on docker distribution \" + dist.getName();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat bundledJdk as archive/rpm/deb-only; docker images bundle their own JDK.","Add a comment on any bundledJdk setting noting which distribution types permit it.","When migrating a distribution to docker, audit for platform and bundledJdk lines to remove."],"tags":["gradle","build-tools","distribution","configuration-validation"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}