{"record":{"id":"829c064a1a9edbf0","repo":"alibaba/DataX","slug":"file-not-found-name","errorCode":null,"errorMessage":"File not found: ${name}","messagePattern":"File not found: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"gdbreader/src/main/java/com/alibaba/datax/plugin/reader/gdbreader/util/ConfigHelper.java","lineNumber":74,"sourceCode":"        return configLabels;\n    }\n\n    static List<Configuration> splitConfig(Configuration config, List<String> labels) {\n        List<Configuration> configs = new ArrayList<>();\n        for (String label : labels) {\n            Configuration conf = config.clone();\n            conf.set(Key.LABEL, label);\n\n            configs.add(conf);\n        }\n        return configs;\n    }\n\n    static Configuration fromClasspath(String name) {\n        try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(name)) {\n            return Configuration.from(is);\n        } catch (IOException e) {\n            throw new IllegalArgumentException(\"File not found: \" + name);\n        }\n    }\n}\n","sourceCodeStart":56,"sourceCodeEnd":78,"githubUrl":"https://github.com/alibaba/DataX/blob/80ec23d5c5328eb90ca364d2749e92dfaf44541e/gdbreader/src/main/java/com/alibaba/datax/plugin/reader/gdbreader/util/ConfigHelper.java#L56-L78","documentation":"ConfigHelper.fromClasspath(name) loads a resource from the thread-context classloader and parses it as a DataX Configuration. If getResourceAsStream returns null, Configuration.from(null) throws (NPE/IOException), and the catch rethrows IllegalArgumentException with the resource name. It is used to load bundled GDB mapping templates from the plugin jar's resources.","triggerScenarios":"Calling fromClasspath with a resource name that is not on the context classloader's classpath — typo in name, resource stripped during a fat-jar/shade repackaging, or code running under a classloader that does not see the plugin jar (TCCL not set to the plugin's loader).","commonSituations":"Custom DataX packaging that drops resources; renaming the template file without updating the caller; running gdbreader unit tests without the resource on the test classpath; nested fat-jar where resources land under BOOT-INF and TCCL cannot see them.","solutions":["Verify the exact resource path string against the file packaged inside the jar (jar tf | grep <name>)","If shading, ensure resource transformers (maven-shade ServicesResourceTransformer / include patterns) keep the file","Set the context classloader (Thread.currentThread().setContextClassLoader(pluginClassLoader)) before invoking when embedding DataX","Add the missing template file under src/main/resources with the expected name"],"exampleFix":"// before\nConfiguration c = ConfigHelper.fromClasspath(\"gdb/mapping.json\");\n// after (fail fast with explicit existence check)\ntry (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(name)) {\n    if (is == null) throw new IllegalArgumentException(\"File not found: \" + name);\n    return Configuration.from(is);\n}","handlingStrategy":"validation","validationCode":"static Configuration fromClasspathChecked(String name) {\n    try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(name)) {\n        if (is == null) throw new IllegalArgumentException(\"File not found: \" + name);\n        return Configuration.from(is);\n    } catch (IOException e) {\n        throw new IllegalArgumentException(\"File not found: \" + name, e);\n    }\n}","typeGuard":null,"tryCatchPattern":"catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"File not found: \")) {\n        // check jar tf <plugin>.jar | grep <name>; fix resource name or packaging\n    }\n}","preventionTips":["Assert resource presence at plugin startup instead of lazily during job run","When shading, configure resource inclusion; keep templates under src/main/resources with stable names"],"tags":["gdb","classpath","resource-loading","datax"],"backgroundTag":null,"analyzedSha":"80ec23d5c5328eb90ca364d2749e92dfaf44541e","analyzedAt":"2026-08-14T15:33:51.187Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}