{"record":{"id":"9483eb4d5e198d91","repo":"apache/seatunnel","slug":"reflect-class-operation-failed","errorCode":"REFLECT_CLASS_OPERATION_FAILED","errorMessage":"REFLECT_CLASS_OPERATION_FAILED","messagePattern":"REFLECT_CLASS_OPERATION_FAILED","errorType":"error_code","errorClass":"SeaTunnelRuntimeException","httpStatus":null,"severity":"error","filePath":"seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java","lineNumber":59,"sourceCode":"import java.util.Objects;\nimport java.util.stream.Collectors;\nimport java.util.stream.Stream;\n\n@Slf4j\npublic class FileUtils {\n\n    public static List<URL> searchJarFiles(@NonNull Path directory) throws IOException {\n        if (!directory.toFile().exists()) {\n            return new ArrayList<>();\n        }\n        try (Stream<Path> paths = Files.walk(directory, FileVisitOption.FOLLOW_LINKS)) {\n            return paths.filter(path -> path.toString().endsWith(\".jar\"))\n                    .map(\n                            path -> {\n                                try {\n                                    return path.toUri().toURL();\n                                } catch (MalformedURLException e) {\n                                    throw new SeaTunnelRuntimeException(\n                                            CommonErrorCodeDeprecated\n                                                    .REFLECT_CLASS_OPERATION_FAILED,\n                                            e);\n                                }\n                            })\n                    .collect(Collectors.toList());\n        }\n    }\n\n    public static String readFileToStr(Path path) {\n        try {\n            byte[] bytes = Files.readAllBytes(path);\n            return new String(bytes);\n        } catch (IOException e) {\n            throw CommonError.fileOperationFailed(\"SeaTunnel\", \"read\", path.toString(), e);\n        }\n    }\n","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java#L41-L77","documentation":"FileUtils.searchJarFiles converts directory paths to URLs while scanning for .jar files. A MalformedURLException (e.g. a malformed/unusable path-to-URI conversion) is rethrown as a SeaTunnelRuntimeException with code REFLECT_CLASS_OPERATION_FAILED.","triggerScenarios":"Calling FileUtils.searchJarFiles(...) on a path whose toUri().toURL() conversion fails — typically due to a malformed plugin path, illegal characters, or an unusable filesystem entry.","commonSituations":"SEATUNNEL_HOME/plugins directory path containing spaces or invalid characters on odd setups; broken symlink or corrupted install dir; custom plugin dirs configured with invalid paths.","solutions":["Fix the plugin/install directory path so it is a valid absolute filesystem path","Check SEATUNNEL_HOME and connector/plugin path env vars for typos or illegal characters","Inspect the wrapped MalformedURLException (cause) for the exact offending URL/path and correct it"],"exampleFix":"// before\nexport SEATUNNEL_HOME=/opt/sea tunnel/  # space breaks URL\n// after\nexport SEATUNNEL_HOME=/opt/seatunnel/","handlingStrategy":"try-catch","validationCode":"Path p = Paths.get(dir);\nif (!Files.isDirectory(p)) throw new IllegalArgumentException(\"not a directory: \" + p);","typeGuard":null,"tryCatchPattern":"try { List<URL> jars = FileUtils.searchJarFiles(dir); } catch (SeaTunnelRuntimeException e) { log.error(\"bad plugin path: {}\", e.getCause()); throw e; }","preventionTips":["Use absolute, well-formed paths without illegal characters for plugin dirs","Verify SEATUNNEL_HOME is a clean install directory","Log the cause chain to identify the malformed URL quickly"],"tags":["file-io","url","plugin-loading"],"backgroundTag":"invalid-url-format","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}