quarkusio/quarkus · error · IllegalStateException

The project is built with Java 17 or higher, but the selecte

Error message

The project is built with Java 17 or higher, but the selected Dockerfile (%s) is using a lower Java version in the base image (%s). Please ensure you are using the proper base image in the Dockerfile.

What it means

Quarkus requires Java 17+ since recent versions. When building a JVM container image, it parses the FROM line of the selected Dockerfile to determine the base image's Java version; if the base image provides Java < 17 the container would fail to run the application, so the build aborts with this IllegalStateException.

Source

Thrown at extensions/container-image/container-image-docker-common/deployment/src/main/java/io/quarkus/container/image/docker/common/deployment/CommonProcessor.java:83

            PackageConfig packageConfig,
            ContainerRuntime... containerRuntimes) {

        var buildContainerImage = buildContainerImageNeeded(containerImageConfig, buildRequest);
        var pushContainerImage = pushContainerImageNeeded(containerImageConfig, pushRequest);

        if (buildContainerImage || pushContainerImage) {
            if (!containerRuntimeStatusBuildItem.isContainerRuntimeAvailable()) {
                throw new RuntimeException(
                        "Unable to build container image. Please check your %s installation."
                                .formatted(getProcessorImplementation()));
            }

            var dockerfilePaths = getDockerfilePaths(config, false, packageConfig, out);
            var dockerfileBaseInformation = DockerFileBaseInformationProvider.impl()
                    .determine(dockerfilePaths.dockerfilePath());

            if (dockerfileBaseInformation.isPresent() && (dockerfileBaseInformation.get().javaVersion() < 17)) {
                throw new IllegalStateException(
                        "The project is built with Java 17 or higher, but the selected Dockerfile (%s) is using a lower Java version in the base image (%s). Please ensure you are using the proper base image in the Dockerfile."
                                .formatted(
                                        dockerfilePaths.dockerfilePath().toAbsolutePath(),
                                        dockerfileBaseInformation.get().baseImage()));
            }

            if (buildContainerImage) {
                LOGGER.infof("Starting (local) container image build for jar using %s", getProcessorImplementation());
            }

            var executableName = getExecutableName(config, containerRuntimes);
            var builtContainerImage = createContainerImage(containerImageConfig, config, containerImageInfo, out,
                    dockerfilePaths, buildContainerImage, pushContainerImage, packageConfig, executableName);

            Optional<BuiltContainerInfo> maybeBuiltContainerInfo = determineBuiltContainerInfo(executableName,
                    builtContainerImage);
            String workingDirectory = null;
            if (maybeBuiltContainerInfo.isPresent()) {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Update the FROM line in the Dockerfile to a Java 17+ base image (e.g. eclipse-temurin:17, registry.access.redhat.com/ubi8/openjdk-17)
  2. Regenerate the default Dockerfiles from a new Quarkus project (src/main/docker/Dockerfile.jvm)
  3. If you intentionally use a custom Dockerfile, ensure its base image tag corresponds to Java 17 or higher
  4. Verify with 'docker run --rm <base-image> java -version'

Example fix

# before
FROM registry.access.redhat.com/ubi8/openjdk-11:1.14
# after
FROM registry.access.redhat.com/ubi8/openjdk-17:1.16
Defensive patterns

Strategy: validation

Validate before calling

String dockerfile = Files.readString(Path.of("src/main/docker/Dockerfile.jvm"));
String from = Arrays.stream(dockerfile.split("\n"))
        .filter(l -> l.strip().startsWith("FROM")).findFirst().orElse("");
if (from.matches(".*(openjdk-1[01]|:1[01]|java-11).*")) {
    throw new IllegalStateException("Base image is below Java 17: " + from.strip());
}

Type guard

boolean isJava17BaseImage(String dockerfileContent) {
    return dockerfileContent.lines()
        .filter(l -> l.strip().toUpperCase().startsWith("FROM"))
        .noneMatch(l -> l.matches(".*\\b(jdk-?1[01]|openjdk-1[01]|:11|:17?)\\s*$".replace("17?", ""))
            && !l.contains("17") && !l.contains("21"));
}

Try / catch

try {
    imageBuild();
} catch (IllegalStateException e) {
    if (e.getMessage().contains("lower Java version")) {
        // update FROM line to a Java 17+ base image and retry
    } else throw e;
}

Prevention

When it happens

Trigger: Building a container image from a jar where src/main/docker/Dockerfile.jvm (or the configured quarkus.container-image.docker.dockerfile-jvm-path) uses an old base image such as registry.access.redhat.com/ubi8/openjdk-11 or eclipse-temurin:11.

Common situations: Projects upgraded from Quarkus 2.x to 3.x but keeping the old generated Dockerfiles; custom Dockerfiles pinned to Java 11; registry mirrors still serving an old tag.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/dbbddff2670924cc. Report an issue: GitHub.