{"id":"37b12cbb42d59a91","repo":"spring-projects/spring-boot","slug":"failed-to-set-file-mode-on-copyspec","errorCode":null,"errorMessage":"Failed to set file mode on CopySpec","messagePattern":"Failed to set file mode on CopySpec","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/ApplicationPluginAction.java","lineNumber":149,"sourceCode":"\t\tAssert.state(stream != null, \"Resource '%s' not found'\".formatted(name));\n\t\treturn stream;\n\t}\n\n\tprivate void configureFilePermissions(CopySpec copySpec, int mode) {\n\t\tif (GradleVersion.current().compareTo(GradleVersion.version(\"8.3\")) >= 0) {\n\t\t\tcopySpec.filePermissions((filePermissions) -> filePermissions.unix(Integer.toString(mode, 8)));\n\t\t}\n\t\telse {\n\t\t\tconfigureFileMode(copySpec, mode);\n\t\t}\n\t}\n\n\tprivate void configureFileMode(CopySpec copySpec, int mode) {\n\t\ttry {\n\t\t\tcopySpec.getClass().getMethod(\"setFileMode\", Integer.class).invoke(copySpec, Integer.valueOf(mode));\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tthrow new RuntimeException(\"Failed to set file mode on CopySpec\", ex);\n\t\t}\n\t}\n\n}\n","sourceCodeStart":131,"sourceCodeEnd":154,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/5b2dbdbb8be64415eb6552f81ff7c449c8d251e6/build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/ApplicationPluginAction.java#L131-L154","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// gradle/wrapper/gradle-wrapper.properties — bump to a supported Gradle\n// before:\n//   distributionUrl=https\\://services.gradle.org/distributions/gradle-8.0-bin.zip\n// after:\n//   distributionUrl=https\\://services.gradle.org/distributions/gradle-8.14-bin.zip\n","handlingStrategy":"validation","validationCode":"// Enforce the supported Gradle floor before applying the plugin\nimport org.gradle.util.GradleVersion\n\nif (GradleVersion.current() < GradleVersion.version(\"8.14\")) {\n    throw GradleException(\"Use Gradle 8.14+ with this Spring Boot version\")\n}\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["gradle","version-compat","reflection","file-permissions","application-plugin"],"analyzedSha":"5b2dbdbb8be64415eb6552f81ff7c449c8d251e6","analyzedAt":"2026-08-04T18:53:14.967Z","schemaVersion":2}