GoogleContainerTools/jib · error · MojoExecutionException

<exception message (IOException | CacheDirectoryCreationExce

Error message

<exception message (IOException | CacheDirectoryCreationException | MainClassInferenceException | InvalidGlobalConfigException)>

What it means

BuildImageMojo.execute groups IOException, CacheDirectoryCreationException, MainClassInferenceException, and InvalidGlobalConfigException and rethrows the underlying message as a MojoExecutionException. These are general build failures: filesystem/IO problems, inability to create the local jib cache, failure to infer a main class, or a corrupt/invalid global jib config (~/.jib/config.json).

Source

Thrown at jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/BuildImageMojo.java:178

      String extensionName = ex.getExtensionClass().getName();
      throw new MojoExecutionException(
          "error running extension '" + extensionName + "': " + ex.getMessage(), ex);

    } catch (IncompatibleBaseImageJavaVersionException ex) {
      throw new MojoExecutionException(
          HelpfulSuggestions.forIncompatibleBaseImageJavaVersionForMaven(
              ex.getBaseImageMajorJavaVersion(), ex.getProjectMajorJavaVersion()),
          ex);

    } catch (InvalidImageReferenceException ex) {
      throw new MojoExecutionException(
          HelpfulSuggestions.forInvalidImageReference(ex.getInvalidReference()), ex);

    } catch (IOException
        | CacheDirectoryCreationException
        | MainClassInferenceException
        | InvalidGlobalConfigException ex) {
      throw new MojoExecutionException(ex.getMessage(), ex);

    } catch (BuildStepsExecutionException ex) {
      throw new MojoExecutionException(ex.getMessage(), ex.getCause());

    } catch (ExtraDirectoryNotFoundException ex) {
      throw new MojoExecutionException(
          "<extraDirectories><paths> contain \"from\" directory that doesn't exist locally: "
              + ex.getPath(),
          ex);
    } finally {
      tempDirectoryProvider.close();
      MojoCommon.finishUpdateChecker(projectProperties, updateCheckFuture);
      projectProperties.waitForLoggingThread();
      getLog().info("");
    }
  }
}

View on GitHub (pinned to fb949e2676)

Solutions

  1. Read the wrapped cause message in the output; it names which of the four failures occurred.
  2. For cache issues, check disk space/permissions or set jib base cache directory to a writable path.
  3. For main class inference, set <mainClass> in the jib configuration or in maven-shade/jar plugin config.
  4. For InvalidGlobalConfigException, delete or fix ~/.jib/config.json.

Example fix

<!-- before: no mainClass, inference fails -->
<plugin>jib-maven-plugin...</plugin>
<!-- after -->
<configuration>
  <mainClass>com.example.Main</mainClass>
</configuration>
Defensive patterns

Strategy: try-catch

Validate before calling

java.io.File cache = new java.io.File(System.getProperty("user.home"), ".cache/google-cloud-tools-jib");
if (!cache.getParentFile().canWrite()) System.err.println("jib cache location not writable");
java.io.File globalCfg = new java.io.File(System.getProperty("user.home"), ".jib/config.json");
if (globalCfg.exists()) new com.fasterxml.jackson.databind.ObjectMapper().readTree(globalCfg);

Try / catch

try { ... } catch (MojoExecutionException e) {
  Throwable c = e.getCause();
  if (c instanceof MainClassInferenceException) { /* set <mainClass> */ }
  else if (c instanceof InvalidGlobalConfigException) { /* fix ~/.jib/config.json */ }
  throw e;
}

Prevention

When it happens

Trigger: Running 'mvn jib:build' where an underlying operation throws IOException, cache directory cannot be created, no main class can be inferred (and none configured), or the global config file is invalid.

Common situations: Read-only or full disk blocking cache creation at ~/.cache/google-cloud-tools-jib; a multi-module or non-executable project with no discoverable main class (no Main-Class and multiple/duplicate main methods); a corrupted ~/.jib/config.json from a manual edit.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06). Data as JSON: /api/errors/5fcb8e90540469ca. Report an issue: GitHub.