{"id":"92fe4e2eda055351","repo":"spring-projects/spring-boot","slug":"failed-to-create","errorCode":null,"errorMessage":"Failed to create {}","messagePattern":"Failed to create (.+?)","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java","lineNumber":143,"sourceCode":"\t\tthis.includeDefaultLoader = includeDefaultLoader;\n\t\tthis.jarmodeToolsLocation = jarmodeToolsLocation;\n\t\tthis.requiresUnpack = requiresUnpack;\n\t\tthis.exclusions = exclusions;\n\t\tthis.librarySpec = librarySpec;\n\t\tthis.compressionResolver = compressionResolver;\n\t\tthis.encoding = encoding;\n\t\tthis.resolvedDependencies = resolvedDependencies;\n\t\tthis.layerResolver = layerResolver;\n\t}\n\n\t@Override\n\tpublic WorkResult execute(CopyActionProcessingStream copyActions) {\n\t\ttry {\n\t\t\twriteArchive(copyActions);\n\t\t\treturn WorkResults.didWork(true);\n\t\t}\n\t\tcatch (IOException ex) {\n\t\t\tthrow new GradleException(\"Failed to create \" + this.output, ex);\n\t\t}\n\t}\n\n\tprivate void writeArchive(CopyActionProcessingStream copyActions) throws IOException {\n\t\tOutputStream output = new FileOutputStream(this.output);\n\t\ttry {\n\t\t\twriteArchive(copyActions, output);\n\t\t}\n\t\tfinally {\n\t\t\tcloseQuietly(output);\n\t\t}\n\t}\n\n\tprivate void writeArchive(CopyActionProcessingStream copyActions, OutputStream output) throws IOException {\n\t\tZipArchiveOutputStream zipOutput = new ZipArchiveOutputStream(output);\n\t\ttry {\n\t\t\tsetEncodingIfNecessary(zipOutput);\n\t\t\tProcessor processor = new Processor(zipOutput);","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/5b2dbdbb8be64415eb6552f81ff7c449c8d251e6/build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java#L125-L161","documentation":"Thrown by BootZipCopyAction.execute() when writeArchive() raises IOException while creating the boot archive (jar/war), wrapped as GradleException with the target output file. This is the top-level failure for any IO problem during the initial creation/opening of the archive output stream or its overall write.","triggerScenarios":"bootJar/bootWar runs BootZipCopyAction.execute(); writeArchive() opens a FileOutputStream on this.output and streams entries; any IOException (cannot create file, permission denied, no space, parent missing, read-only FS) propagates to line 143.","commonSituations":"Disk full; output directory not writable; the target jar is locked by another process (IDE/Windows); build directory on a read-only or network filesystem; path too long; antivirus interference; out of inodes.","solutions":["Confirm the output directory exists and is writable, and that the target jar is not open elsewhere.","Free disk space / inodes on the build volume.","Run ./gradlew clean to remove a possibly half-written/corrupt output.","On Windows, close IDEs/agents that may lock build/libs/*.jar, or add the dir to antivirus exclusions."],"exampleFix":"// shell: ensure clean, writable output\n//   ./gradlew clean bootJar --info\n// build.gradle.kts: redirect output if needed\ntasks.named<org.springframework.boot.gradle.tasks.bundling.BootJar>('bootJar') {\n    archiveFileName.set('app.jar')\n    destinationDirectory.set(layout.buildDirectory.dir('libs'))\n}\n","handlingStrategy":"try-catch","validationCode":"import java.io.File\nval outDir = layout.buildDirectory.dir(\"libs\").get().asFile\nif (!outDir.exists() && !outDir.mkdirs()) {\n    throw GradleException(\"Cannot create output dir ${outDir.absolutePath}\")\n}\nif (!outDir.canWrite()) {\n    throw GradleException(\"Output dir ${outDir.absolutePath} is not writable\")\n}\n","typeGuard":null,"tryCatchPattern":"try {\n    tasks.named(\"bootJar\").get().actions\n    gradle.taskGraph.whenReady { /* run */ }\n} catch (ex: org.gradle.api.GradleException) {\n    if (ex.message?.startsWith(\"Failed to create \") == true) {\n        logger.error(\"Cannot write the archive. Check disk space, permissions, and file locks.\")\n    }\n    throw ex\n}\n","preventionTips":["Ensure the build volume has free space and is writable.","Close IDEs/processes that lock build/libs/*.jar on Windows.","Exclude the build directory from antivirus scanning."],"tags":["gradle","boot-archive","io","disk","permissions"],"analyzedSha":"5b2dbdbb8be64415eb6552f81ff7c449c8d251e6","analyzedAt":"2026-08-04T18:53:14.967Z","schemaVersion":2}