GoogleContainerTools/jib · error · GradleException
Your project is using Java ${projectMajorJavaVersion} but th
Error message
Your project is using Java ${projectMajorJavaVersion} but the base image is for Java ${baseImageMajorJavaVersion}, perhaps you should configure a Java ${projectMajorJavaVersion}-compatible base image using the 'jib.from.image' parameter, or set targetCompatibility = ${baseImageMajorJavaVersion} or below in your build configuration What it means
Thrown when the base image's Java major version is lower than the project's Java version, i.e. the base image cannot run the compiled bytecode. Jib detects the Java version of the base image (e.g. from eu.gcr.io/jib-core base images like eclipse-temurin:8) and fails with a helpful suggestion via HelpfulSuggestions.forIncompatibleBaseImageJavaVersionForGradle.
Source
Thrown at jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/BuildDockerTask.java:175
+ "DateTimeFormatter.ISO_DATE_TIME) or special keyword \"EPOCH_PLUS_SECOND\": "
+ ex.getInvalidFilesModificationTime(),
ex);
} catch (InvalidCreationTimeException ex) {
throw new GradleException(
"container.creationTime should be an ISO 8601 date-time (see "
+ "DateTimeFormatter.ISO_DATE_TIME) or a special keyword (\"EPOCH\", "
+ "\"USE_CURRENT_TIMESTAMP\"): "
+ ex.getInvalidCreationTime(),
ex);
} catch (JibPluginExtensionException ex) {
String extensionName = ex.getExtensionClass().getName();
throw new GradleException(
"error running extension '" + extensionName + "': " + ex.getMessage(), ex);
} catch (IncompatibleBaseImageJavaVersionException ex) {
throw new GradleException(
HelpfulSuggestions.forIncompatibleBaseImageJavaVersionForGradle(
ex.getBaseImageMajorJavaVersion(), ex.getProjectMajorJavaVersion()),
ex);
} catch (InvalidImageReferenceException ex) {
throw new GradleException(
HelpfulSuggestions.forInvalidImageReference(ex.getInvalidReference()), ex);
} catch (ExtraDirectoryNotFoundException ex) {
throw new GradleException(
"extraDirectories.paths contain \"from\" directory that doesn't exist locally: "
+ ex.getPath(),
ex);
} finally {
tempDirectoryProvider.close();
TaskCommon.finishUpdateChecker(projectProperties, updateCheckFuture);
projectProperties.waitForLoggingThread();
}View on GitHub (pinned to fb949e2676)
Solutions
- Update jib.from.image to a base image matching your Java version, e.g. 'eclipse-temurin:17-jre'
- Or lower targetCompatibility/sourceCompatibility to the base image's Java version
- Or configure a Java toolchain matching the base image
- Check the reported versions in the error message to pick the right image tag
Example fix
// before
jib { from { image = 'openjdk:8-jre' } } // project targets Java 17
// after
jib { from { image = 'eclipse-temurin:17-jre' } } Defensive patterns
Strategy: validation
Validate before calling
def projectJava = JavaVersion.current().majorVersion.toInteger()
def baseImage = jib.from.image ?: 'eclipse-temurin:8-jre'
def baseJava = (baseImage =~ /:(\d+)/) ? ((baseImage =~ /:(\d+)/)[0][1] as Integer) : 8
if (projectJava > baseJava) {
logger.warn("Project Java $projectJava > base image Java $baseJava — update jib.from.image")
} Try / catch
try { jibBuild.run() } catch (GradleException e) { if (e.message.contains('base image is for Java')) { logger.error(e.message + " — align jib.from.image with targetCompatibility") }; throw e } Prevention
- When upgrading the project's JDK, update jib.from.image in the same change
- Keep base image Java version >= project targetCompatibility
- Use Jib's default base image matching your toolchain, or pin explicit versioned tags
When it happens
Trigger: Building a project with source/targetCompatibility (or toolchain) Java 17 while using a base image built for Java 8 or 11 (e.g. 'openjdk:8-jre'), so the compiled classes (class file version) would not run on the base image's JRE.
Common situations: Upgrading a project to a newer JDK without updating jib.from.image; inheriting an old base image from a template; CI using a newer JDK than the Dockerfile-era base image.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- HelpfulSuggestions.forIncompatibleBaseImageJavaVersionForGra
- HelpfulSuggestions.forIncompatibleBaseImageJavaVersionForGra
- The input JAR (${jarPath}) is compiled with Java ${jarJavaVe
- <message from IncompatibleBaseImageJavaVersionException via
- <message from IncompatibleBaseImageJavaVersionException via
AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06).
Data as JSON: /api/errors/fb9258b9834c1492.
Report an issue: GitHub.