{"record":{"id":"5e7d39d88a37dbb5","repo":"GoogleContainerTools/jib","slug":"please-set-the-app-root-of-the-container-with-a","errorCode":null,"errorMessage":"Please set the app root of the container with `--app-root` when specifying a base image that is not jetty.","messagePattern":"Please set the app root of the container with `--app-root` when specifying a base image that is not jetty\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"jib-cli/src/main/java/com/google/cloud/tools/jib/cli/ArtifactProcessors.java","lineNumber":107,"sourceCode":"  /**\n   * Creates a {@link ArtifactProcessor} instance.\n   *\n   * @param warPath path to the war\n   * @param cacheDirectories the location of the relevant caches\n   * @param warOptions war cli options\n   * @param commonContainerConfigCliOptions common cli options shared between jar and war command\n   * @return ArtifactProcessor\n   * @throws InvalidImageReferenceException if base image reference is invalid\n   */\n  public static ArtifactProcessor fromWar(\n      Path warPath,\n      CacheDirectories cacheDirectories,\n      War warOptions,\n      CommonContainerConfigCliOptions commonContainerConfigCliOptions)\n      throws InvalidImageReferenceException {\n    Optional<AbsoluteUnixPath> appRoot = warOptions.getAppRoot();\n    if (!commonContainerConfigCliOptions.isJettyBaseimage() && !appRoot.isPresent()) {\n      throw new IllegalArgumentException(\n          \"Please set the app root of the container with `--app-root` when specifying a base image that is not jetty.\");\n    }\n    AbsoluteUnixPath chosenAppRoot = appRoot.orElse(AbsoluteUnixPath.get(DEFAULT_JETTY_APP_ROOT));\n    return new StandardWarExplodedProcessor(\n        warPath, cacheDirectories.getExplodedArtifactDirectory(), chosenAppRoot);\n  }\n\n  /**\n   * Determines whether the jar is a spring boot or standard jar.\n   *\n   * @param jarPath path to the jar\n   * @return the jar type\n   * @throws IOException if I/O error occurs when opening the file\n   */\n  private static String determineJarType(Path jarPath) throws IOException {\n    try (JarFile jarFile = new JarFile(jarPath.toFile())) {\n      if (jarFile.getEntry(\"BOOT-INF\") != null) {\n        return SPRING_BOOT;","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-cli/src/main/java/com/google/cloud/tools/jib/cli/ArtifactProcessors.java#L89-L125","documentation":"When building from a WAR, the default app root (/var/jetty/webapps or similar) only applies to jetty-based base images. If the selected base image is not jetty and --app-root was not provided, ArtifactProcessors.fromWar() throws IllegalArgumentException because the deploy path would be wrong for that base image.","triggerScenarios":"Running `jib war app.war` with a non-jetty --from base image and no --app-root option.","commonSituations":"Switching to a Tomcat or distroless base image for a WAR while keeping jib-cli's jetty defaults; forgetting --app-root after changing --from.","solutions":["Add --app-root=/desired/deploy/path to the jib command","Switch back to a jetty base image if the default app root is intended","Set the app root programmatically via warOptions.setAppRoot(AbsoluteUnixPath.get(\"/...\"))"],"exampleFix":"// before\njib war --from=tomcat:10 --target=gcr.io/project/app app.war\n// after\njib war --from=tomcat:10 --app-root=/usr/local/tomcat/webapps/ROOT --target=gcr.io/project/app app.war","handlingStrategy":"validation","validationCode":"if (!\"jetty\".contains(fromImage.toLowerCase()) && appRoot == null) { /* require --app-root */ }","typeGuard":null,"tryCatchPattern":"try { processor.fromWar(warPath, ...); } catch (IllegalArgumentException e) { /* re-run with --app-root set */ }","preventionTips":["Always pass --app-root when using a non-jetty base image for WARs","Centralize jib CLI invocation defaults so --from changes come with --app-root","Prefer jetty base images unless a custom app root is configured"],"tags":["jib","cli","war","missing-flag"],"backgroundTag":"missing-required-flag","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"}