spring-projects/spring-boot · error · RuntimeException
Failed to get file mode from CopySpec
Error message
Failed to get file mode from CopySpec
What it means
Thrown by BootArchiveSupport.getFileMode() when reflective invocation of CopySpec.getFileMode() fails. Like getDirMode(), this fallback is only selected on Gradle < 8.3; on 8.3+ getFilePermissions().toUnixNumeric() is used. With the plugin's 8.14 floor this branch should not be hit in normal operation.
Source
Thrown at build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootArchiveSupport.java:167
private @Nullable Integer asUnixNumeric(Property<ConfigurableFilePermissions> permissions) {
return permissions.isPresent() ? permissions.get().toUnixNumeric() : null;
}
private @Nullable Integer getDirMode(CopySpec copySpec) {
try {
return (Integer) copySpec.getClass().getMethod("getDirMode").invoke(copySpec);
}
catch (Exception ex) {
throw new RuntimeException("Failed to get dir mode from CopySpec", ex);
}
}
private @Nullable Integer getFileMode(CopySpec copySpec) {
try {
return (Integer) copySpec.getClass().getMethod("getFileMode").invoke(copySpec);
}
catch (Exception ex) {
throw new RuntimeException("Failed to get file mode from CopySpec", ex);
}
}
private boolean isUsingDefaultLoader(Jar jar) {
return DEFAULT_LAUNCHER_CLASSES.contains(jar.getManifest().getAttributes().get("Main-Class"));
}
void requiresUnpack(String... patterns) {
this.requiresUnpack.include(patterns);
}
void requiresUnpack(Spec<FileTreeElement> spec) {
this.requiresUnpack.include(spec);
}
void excludeNonZipLibraryFiles(FileCopyDetails details) {
if (this.librarySpec.isSatisfiedBy(details)) {
excludeNonZipFiles(details);View on GitHub (pinned to 5b2dbdbb8b)
Solutions
- Upgrade Gradle to 8.14 or later.
- Confirm the CopySpec used by bootJar/bootWar is a standard Gradle CopySpec.
- Check that no JVM --illegal-access or module flags block reflection on Gradle classes.
Example fix
// gradle/wrapper/gradle-wrapper.properties // before: // distributionUrl=...gradle-8.2-bin.zip // after: // distributionUrl=...gradle-8.14-bin.zip
Defensive patterns
Strategy: validation
Validate before calling
import org.gradle.util.GradleVersion
require(GradleVersion.current() >= GradleVersion.version("8.3")) {
"Boot archive file mode requires Gradle 8.3+ (use 8.14+)"
}
Prevention
- Use Gradle 8.14+ so the filePermissions path is selected.
- Ensure CopySpec instances are standard Gradle implementations.
When it happens
Trigger: getUnixNumericFilePermissions() routes to getFileMode() when GradleVersion.current() < 8.3; the reflective getMethod("getFileMode").invoke(copySpec) throws, wrapped as RuntimeException at line 167.
Common situations: Unsupported old Gradle; custom CopySpec without getFileMode; reflective access blocked by JVM security/module settings.
Related errors
- Failed to get dir mode from CopySpec
- Failed to get mode from FileCopyDetails
- Failed to set file mode on CopySpec
- Spring Boot plugin requires Gradle 8.x (8.14 or later) or 9.
- Failed to create {}
AI-assisted analysis of spring-projects/spring-boot@5b2dbdbb8b (2026-08-04).
Data as JSON: /data/errors/3d5cdfb97d0ef678.json.
Report an issue: GitHub.