spring-projects/spring-boot · error · RuntimeException
Failed to set file mode on CopySpec
Error message
Failed to set file mode on CopySpec
What it means
Thrown by ApplicationPluginAction.configureFileMode, the legacy fallback path that uses reflection to invoke CopySpec.setFileMode(Integer) on Gradle versions older than 8.3 (the code above checks GradleVersion 8.3 to decide between the modern filePermissions API and this reflective path). The exception wraps any reflection failure: NoSuchMethodException, IllegalAccessException, or InvocationTargetException.
Solutions
- Upgrade Gradle to 8.3 or later, which uses the modern filePermissions API and avoids this reflective path entirely.
- If you must stay on an older Gradle, ensure no custom CopySpec implementation overrides the default Gradle API surface.
- Check for conflicting plugins that replace or wrap CopySpec types and remove or update them.
Example fix
// before: running on Gradle 7.x with spring-boot-gradle-plugin // Upgrade gradle-wrapper.properties distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip // after: Gradle 8.14+ uses filePermissions() directly, never hits configureFileMode reflection
Defensive patterns
Strategy: validation
Validate before calling
// In settings.gradle or build.gradle, gate the plugin on Gradle version before apply.
if (GradleVersion.current().compareTo(GradleVersion.version("8.3")) < 0) {
throw new GradleException("Use Gradle 8.3+ to avoid reflective setFileMode fallback.")
} Prevention
- Standardize on Gradle 8.3+ (preferably the plugin's required minimum, 8.14) in the wrapper.
- Do not replace the standard CopySpec with a custom subclass.
- Keep the Gradle wrapper version and the Spring Boot plugin version aligned per the compatibility matrix.
When it happens
Trigger: Running a Spring Boot Gradle task that applies file permissions to a CopySpec (e.g. bootJar, bootDistZip, startScripts) on a Gradle version that routes through configureFileMode (below 8.3) but whose CopySpec implementation does not expose a setFileMode(Integer) method. This can happen on unusual Gradle distributions or when a third-party plugin replaces the CopySpec implementation.
Common situations: Using a very old or non-standard Gradle version (< 8.3) where the reflective method signature has changed or been removed. Using a Gradle fork or a custom CopySpec subclass that lacks setFileMode. Running against a Gradle version where the method exists but throws internally (e.g. permissions already locked).
Related errors
- Failed to get dir mode from CopySpec
- Failed to get file mode from CopySpec
- Failed to get mode from FileCopyDetails
- Spring Boot plugin requires Gradle 8.x (8.14 or later) or…
- Each image building cache can be configured only once
AI-assisted analysis of spring-projects/spring-boot@270dfe353f (2026-08-11).
Data as JSON: /api/errors/37b12cbb42d59a91.
Report an issue: GitHub.
Appendix: source
Thrown at build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/ApplicationPluginAction.java:149
Assert.state(stream != null, "Resource '%s' not found'".formatted(name));
return stream;
}
private void configureFilePermissions(CopySpec copySpec, int mode) {
if (GradleVersion.current().compareTo(GradleVersion.version("8.3")) >= 0) {
copySpec.filePermissions((filePermissions) -> filePermissions.unix(Integer.toString(mode, 8)));
}
else {
configureFileMode(copySpec, mode);
}
}
private void configureFileMode(CopySpec copySpec, int mode) {
try {
copySpec.getClass().getMethod("setFileMode", Integer.class).invoke(copySpec, Integer.valueOf(mode));
}
catch (Exception ex) {
throw new RuntimeException("Failed to set file mode on CopySpec", ex);
}
}
}
View on GitHub (pinned to 270dfe353f)