GoogleContainerTools/jib · error · MojoExecutionException
<exception message (IOException | CacheDirectoryCreationExce
Error message
<exception message (IOException | CacheDirectoryCreationException | MainClassInferenceException | InvalidGlobalConfigException)>
What it means
Catch-all in BuildTarMojo.execute for IOException, CacheDirectoryCreationException, MainClassInferenceException, and InvalidGlobalConfigException: the original exception message is re-wrapped in a MojoExecutionException. The real cause varies — filesystem I/O failures, inability to create Jib's cache directory, failure to infer a main class from the project, or a corrupt/invalid ~/.jib global config file.
Source
Thrown at jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/BuildTarMojo.java:156
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
- Read the wrapped message and 'Caused by' chain in Maven output to identify which of the four exceptions occurred.
- If MainClassInferenceException: set <container><mainClass> explicitly to your main class FQN.
- If cache creation fails: check permissions/disk space for the cache directory (default under build dir or ~/.cache), or set <cache> / jib.cacheDirectory explicitly.
- If InvalidGlobalConfigException: fix or delete ~/.jib/config.json and rerun.
- If plain IOException: inspect the caused-by for the underlying file path and fix permissions or disk space.
Example fix
// before (no mainClass in non-boot project) <container></container> // after <container><mainClass>com.example.Main</mainClass></container>
Defensive patterns
Strategy: try-catch
Try / catch
// In Maven: always inspect the cause chain mvn jib:buildTar -e // In automation: retry only IOException-class failures once; treat MainClassInference/ // InvalidGlobalConfig/cache-permission failures as fatal configuration problems.
Prevention
- Explicitly set <container><mainClass> in non-Spring-Boot jar projects.
- Ensure the build machine has writable disk space for Jib's cache directory.
- Never hand-edit ~/.jib/config.json without validating JSON afterwards.
- Run a clean build (delete target/jib-cache) if cache state is suspect.
When it happens
Trigger: Running a jib goal when the local cache directory cannot be created (permissions/disk), when a jar can't be read/written, when no class with a main method exists and none is configured (<mainClass> missing in a non-boot project), or when the Jib global config JSON is invalid.
Common situations: Non-Spring-Boot jar projects without <container><mainClass>; read-only or full disks; ~/.jib/config.json hand-edited into invalid JSON; antivirus/permission issues locking cache directories.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- <exception message (IOException | CacheDirectoryCreationExce
- <container><appRoot> is not an absolute Unix-style path: ${e
- invalid value for <containerizingMode>: ${ex.getInvalidConta
- <container><appRoot> is not an absolute Unix-style path: <in
- invalid value for <containerizingMode>: <invalidContainerizi
AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06).
Data as JSON: /api/errors/31bab528f8c8949b.
Report an issue: GitHub.