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() when the reflective invocation of CopySpec.setFileMode(Integer) fails. This reflective fallback is only reached on Gradle < 8.3 (the filePermissions API did not exist yet); on Gradle 8.3+ the modern filePermissions(...) path is used instead. Because SpringBootPlugin now requires Gradle 8.14+, this branch is effectively dead code in supported configurations, so seeing it implies a very old or non-standard Gradle/CopySpec.
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 5b2dbdbb8b)
Solutions
- Upgrade Gradle to 8.14 or later (the plugin's declared minimum) so the modern filePermissions path is used.
- Verify GradleVersion.current() reports the real version (check for gradle-wrapper.jar tampering or GRADLE_USER_HOME overrides).
- If you supply a custom CopySpec into the boot distribution, ensure it is a standard Gradhe CopySpec that supports setFileMode or use Gradle >= 8.3.
Example fix
// gradle/wrapper/gradle-wrapper.properties — bump to a supported Gradle // before: // distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip // after: // distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
Defensive patterns
Strategy: validation
Validate before calling
// Enforce the supported Gradle floor before applying the plugin
import org.gradle.util.GradleVersion
if (GradleVersion.current() < GradleVersion.version("8.14")) {
throw GradleException("Use Gradle 8.14+ with this Spring Boot version")
}
Prevention
- Pin the Gradle wrapper to 8.14 or later.
- Fail the build early if GradleVersion.current() is below the supported floor.
- Do not pass custom CopySpec implementations into the boot distribution.
When it happens
Trigger: configureFilePermissions() routes to configureFileMode() only when GradleVersion.current() < 8.3; inside it copySpec.getClass().getMethod("setFileMode", Integer.class).invoke(...) throws NoSuchMethodException/IllegalAccessException/InvocationTargetException, wrapped as RuntimeException at line 149.
Common situations: Running the plugin against a Gradle older than the supported floor; a custom CopySpec implementation that does not expose setFileMode; security manager / module restrictions blocking reflective access to Gradle internals.
Related errors
- Failed to get dir mode from CopySpec
- Failed to get file mode from CopySpec
- Failed to get mode from FileCopyDetails
- Failed to read '{}'
- Main class name has not been configured and it could not be
AI-assisted analysis of spring-projects/spring-boot@5b2dbdbb8b (2026-08-04).
Data as JSON: /data/errors/37b12cbb42d59a91.json.
Report an issue: GitHub.