{"record":{"id":"cad24bb8c7216af4","repo":"GoogleContainerTools/jib","slug":"helpfulsuggestions-forincompatiblebaseimagejavaver","errorCode":null,"errorMessage":"HelpfulSuggestions.forIncompatibleBaseImageJavaVersionForGradle(${ex.getBaseImageMajorJavaVersion()}, ${ex.getProjectMajorJavaVersion()})","messagePattern":"HelpfulSuggestions\\.forIncompatibleBaseImageJavaVersionForGradle\\((.+?), (.+?)\\)","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/BuildImageTask.java","lineNumber":171,"sourceCode":"              + ex.getInvalidFilesModificationTime(),\n          ex);\n\n    } catch (InvalidCreationTimeException ex) {\n      throw new GradleException(\n          \"container.creationTime should be an ISO 8601 date-time (see \"\n              + \"DateTimeFormatter.ISO_DATE_TIME) or a special keyword (\\\"EPOCH\\\", \"\n              + \"\\\"USE_CURRENT_TIMESTAMP\\\"): \"\n              + ex.getInvalidCreationTime(),\n          ex);\n\n    } catch (JibPluginExtensionException ex) {\n      String extensionName = ex.getExtensionClass().getName();\n      throw new GradleException(\n          \"error running extension '\" + extensionName + \"': \" + ex.getMessage(), ex);\n\n    } catch (IncompatibleBaseImageJavaVersionException ex) {\n      throw new GradleException(\n          HelpfulSuggestions.forIncompatibleBaseImageJavaVersionForGradle(\n              ex.getBaseImageMajorJavaVersion(), ex.getProjectMajorJavaVersion()),\n          ex);\n\n    } catch (InvalidImageReferenceException ex) {\n      throw new GradleException(\n          HelpfulSuggestions.forInvalidImageReference(ex.getInvalidReference()), ex);\n\n    } catch (ExtraDirectoryNotFoundException ex) {\n      throw new GradleException(\n          \"extraDirectories.paths contain \\\"from\\\" directory that doesn't exist locally: \"\n              + ex.getPath(),\n          ex);\n    } finally {\n      tempDirectoryProvider.close();\n      TaskCommon.finishUpdateChecker(projectProperties, updateCheckFuture);\n      projectProperties.waitForLoggingThread();\n    }\n  }","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/BuildImageTask.java#L153-L189","documentation":"Jib refuses to build when the base image's Java major version is older than the project's compiled Java major version (e.g. project compiled with Java 17 but base image provides Java 11), because the container would fail at runtime with UnsupportedClassVersionError. Jib detects the base image's Java version and throws IncompatibleBaseImageJavaVersionException, wrapped by this GradleException with HelpfulSuggestions text naming both versions.","triggerScenarios":"Running gradle jib or jibBuild where the project's sourceCompatibility/targetCompatibility Java major version exceeds the Java version found in the base image configured via jib.from.image (e.g. base image eclipse-temurin:11 while project targets 17).","commonSituations":"Upgrading the project to a newer JDK but forgetting to bump the base image; using an old Dockerfile-era base image tag; base image with no Java (Jib cannot match versions); copying base-image config from an older project.","solutions":["Upgrade the base image to one matching or exceeding the project's Java version, e.g. jib { from { image = 'eclipse-temurin:17' } }","Or lower the project's Java target (sourceCompatibility/targetCompatibility) to match the base image","Verify the base image actually provides the needed Java runtime by checking the image's documentation or running it and checking java -version","If intentional, pick a distroless/JRE tag variant explicitly matching the project major version"],"exampleFix":"// before (project targets Java 17)\njib { from { image = 'gcr.io/distroless/java:11' } }\n// after\njib { from { image = 'gcr.io/distroless/java17-debian11' } }","handlingStrategy":"validation","validationCode":"def projectJava = Integer.parseInt(project.java.targetCompatibility.majorVersion)\ndef baseImageJava = 17 // match your jib.from.image runtime\ndef baseImage = project.jib.from.image.get()\ndef javaBaseMap = ['gcr.io/distroless/java':11, 'gcr.io/distroless/java17-debian11':17]\nassert javaBaseMap.getOrDefault(baseImage.split(':').first(), projectJava) >= projectJava : 'Base image Java too old for project'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always bump the base image tag when raising sourceCompatibility/targetCompatibility","Use versioned base image tags (e.g. distroless/java17) that encode the Java version","Add a CI check comparing project Java version to the configured base image"],"tags":["jib","gradle","java-version","base-image","compatibility"],"backgroundTag":"incompatible-java-version","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}