{"record":{"id":"31bab528f8c8949b","repo":"GoogleContainerTools/jib","slug":"exception-message-ioexception-cachedirectorycr-31bab5","errorCode":null,"errorMessage":"<exception message (IOException | CacheDirectoryCreationException | MainClassInferenceException | InvalidGlobalConfigException)>","messagePattern":"<exception message \\(IOException \\| CacheDirectoryCreationException \\| MainClassInferenceException \\| InvalidGlobalConfigException\\)>","errorType":"exception","errorClass":"MojoExecutionException","httpStatus":null,"severity":"error","filePath":"jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/BuildTarMojo.java","lineNumber":156,"sourceCode":"      String extensionName = ex.getExtensionClass().getName();\n      throw new MojoExecutionException(\n          \"error running extension '\" + extensionName + \"': \" + ex.getMessage(), ex);\n\n    } catch (IncompatibleBaseImageJavaVersionException ex) {\n      throw new MojoExecutionException(\n          HelpfulSuggestions.forIncompatibleBaseImageJavaVersionForMaven(\n              ex.getBaseImageMajorJavaVersion(), ex.getProjectMajorJavaVersion()),\n          ex);\n\n    } catch (InvalidImageReferenceException ex) {\n      throw new MojoExecutionException(\n          HelpfulSuggestions.forInvalidImageReference(ex.getInvalidReference()), ex);\n\n    } catch (IOException\n        | CacheDirectoryCreationException\n        | MainClassInferenceException\n        | InvalidGlobalConfigException ex) {\n      throw new MojoExecutionException(ex.getMessage(), ex);\n\n    } catch (BuildStepsExecutionException ex) {\n      throw new MojoExecutionException(ex.getMessage(), ex.getCause());\n\n    } catch (ExtraDirectoryNotFoundException ex) {\n      throw new MojoExecutionException(\n          \"<extraDirectories><paths> contain \\\"from\\\" directory that doesn't exist locally: \"\n              + ex.getPath(),\n          ex);\n    } finally {\n      tempDirectoryProvider.close();\n      MojoCommon.finishUpdateChecker(projectProperties, updateCheckFuture);\n      projectProperties.waitForLoggingThread();\n      getLog().info(\"\");\n    }\n  }\n}\n","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/BuildTarMojo.java#L138-L174","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (no mainClass in non-boot project)\n<container></container>\n// after\n<container><mainClass>com.example.Main</mainClass></container>","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// In Maven: always inspect the cause chain\nmvn jib:buildTar -e\n// In automation: retry only IOException-class failures once; treat MainClassInference/\n// InvalidGlobalConfig/cache-permission failures as fatal configuration problems.","preventionTips":["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."],"tags":["maven","jib","io","cache","configuration"],"backgroundTag":"file-write-failed","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"}