spring-projects/spring-boot · error · GradleException
Failed to create
Error message
Failed to create {} What it means
Thrown by BootZipCopyAction.execute when writeArchive(copyActions) throws an IOException. This is the top-level catch around the entire archive-writing loop that creates the output boot JAR/WAR/zip. The message names this.output (the target archive File). Any I/O failure during the creation of the archive file bubbles up here.
Solutions
- Run 'gradle clean' to remove stale outputs, then rebuild.
- Verify the build output directory (build/libs) exists and is writable: 'ls -la build/libs' and check permissions.
- Close IDEs or file-locking tools that may hold the output JAR, or add the build directory to their exclusion lists.
- Check available disk space: 'df -h .'
- Run with '--no-daemon' to rule out a daemon holding a file lock.
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check output writability before the build.
File outDir = new File(project.buildDir, "libs");
if (!outDir.exists() && !outDir.mkdirs()) {
throw new GradleException("Cannot create output dir: " + outDir);
}
if (!outDir.canWrite()) {
throw new GradleException("Output dir not writable: " + outDir);
} Try / catch
// Catch GradleException around the bootJar/bootWar task and inspect the cause.
try {
project.getTasks().named("bootJar").get().copy();
} catch (GradleException ex) {
if (ex.getCause() instanceof IOException) {
// handle I/O: disk full, permissions, lock
}
throw ex;
} Prevention
- Run 'gradle clean' to remove stale/locked outputs.
- Ensure the build directory is on a local writable filesystem.
- Close IDEs/tools that may lock the output JAR, or exclude the build dir from them.
- Check disk space before large builds.
When it happens
Trigger: Any IOException while creating the output archive: cannot open FileOutputStream(this.output) (permissions, path does not exist, file is locked), disk full during write, or the output stream is closed unexpectedly.
Common situations: The output directory does not exist or is not writable. Another process (IDE, file watcher, previous daemon) holds a lock on the output file. Disk full. Building into a network-mounted directory that drops. Antivirus scanning locks the file mid-write.
Related errors
- Failed to add to
- Failed to get mode from FileCopyDetails
- Failed to read main class name from
- Error reading Docker configuration file
- Failed to get dir mode from CopySpec
AI-assisted analysis of spring-projects/spring-boot@270dfe353f (2026-08-11).
Data as JSON: /api/errors/92fe4e2eda055351.
Report an issue: GitHub.
Appendix: source
Thrown at build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java:143
this.includeDefaultLoader = includeDefaultLoader;
this.jarmodeToolsLocation = jarmodeToolsLocation;
this.requiresUnpack = requiresUnpack;
this.exclusions = exclusions;
this.librarySpec = librarySpec;
this.compressionResolver = compressionResolver;
this.encoding = encoding;
this.resolvedDependencies = resolvedDependencies;
this.layerResolver = layerResolver;
}
@Override
public WorkResult execute(CopyActionProcessingStream copyActions) {
try {
writeArchive(copyActions);
return WorkResults.didWork(true);
}
catch (IOException ex) {
throw new GradleException("Failed to create " + this.output, ex);
}
}
private void writeArchive(CopyActionProcessingStream copyActions) throws IOException {
OutputStream output = new FileOutputStream(this.output);
try {
writeArchive(copyActions, output);
}
finally {
closeQuietly(output);
}
}
private void writeArchive(CopyActionProcessingStream copyActions, OutputStream output) throws IOException {
ZipArchiveOutputStream zipOutput = new ZipArchiveOutputStream(output);
try {
setEncodingIfNecessary(zipOutput);
Processor processor = new Processor(zipOutput);View on GitHub (pinned to 270dfe353f)