{"record":{"id":"bcb845ed736c8c61","repo":"GoogleContainerTools/jib","slug":"getting-the-java-version-from-a-war-file-is-curren","errorCode":null,"errorMessage":"Getting the java version from a WAR file is currently not supported.","messagePattern":"Getting the java version from a WAR file is currently not supported\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"jib-cli/src/main/java/com/google/cloud/tools/jib/cli/war/StandardWarExplodedProcessor.java","lineNumber":127,"sourceCode":"    }\n    if (!resourcesLayer.getEntries().isEmpty()) {\n      layers.add(resourcesLayer);\n    }\n    if (!classesLayer.getEntries().isEmpty()) {\n      layers.add(classesLayer);\n    }\n\n    return layers;\n  }\n\n  @Override\n  public ImmutableList<String> computeEntrypoint(List<String> jvmFlags) {\n    throw new UnsupportedOperationException(\"Computing the entrypoint is currently not supported.\");\n  }\n\n  @Override\n  public Integer getJavaVersion() {\n    throw new UnsupportedOperationException(\n        \"Getting the java version from a WAR file is currently not supported.\");\n  }\n}\n","sourceCodeStart":109,"sourceCodeEnd":131,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-cli/src/main/java/com/google/cloud/tools/jib/cli/war/StandardWarExplodedProcessor.java#L109-L131","documentation":"getJavaVersion for an exploded WAR is intentionally unimplemented: WAR archives do not carry Java version metadata the way Jib's Java layer processing expects. Any call throws UnsupportedOperationException.","triggerScenarios":"Any call to getJavaVersion() on StandardWarExplodedProcessor, typically when Jib's containerizing pipeline attempts to determine the target Java runtime version from a WAR input.","commonSituations":"Building with a WAR input where Jib tries to pick/validate the base image Java version; automated flows that query getJavaVersion for all application types.","solutions":["Explicitly specify the Java version / base image (e.g. a JDK 17 Tomcat image) rather than letting Jib infer it from the WAR","Avoid querying getJavaVersion for WAR inputs; branch on application type before calling","Package as a JAR if Java-version inference is required"],"exampleFix":"// before\nInteger v = processor.getJavaVersion();  // throws for WARs\n// after\nif (processor instanceof WarProcessor) { v = userSuppliedJavaVersion; }","handlingStrategy":"try-catch","validationCode":"if (processor instanceof StandardWarExplodedProcessor) { javaVersion = explicitlyConfiguredVersion; } else { javaVersion = processor.getJavaVersion(); }","typeGuard":"boolean supportsJavaVersionLookup(JibProcessor p) { return !(p instanceof StandardWarExplodedProcessor); }","tryCatchPattern":"try { v = processor.getJavaVersion(); } catch (UnsupportedOperationException e) { v = configuredJavaVersion; }","preventionTips":["Always specify the base image/Java version explicitly for WAR builds","Avoid polymorphic calls to getJavaVersion across mixed app types","Document that WAR inputs require manual Java version selection"],"tags":["jib","war","java-version","unsupported"],"backgroundTag":"operation-not-supported","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}