{"record":{"id":"c0ff13f505836b8c","repo":"apache/flink","slug":"unable-to-instantiate-the-hadoop-inputsplit","errorCode":null,"errorMessage":"Unable to instantiate the Hadoop InputSplit","messagePattern":"Unable to instantiate the Hadoop InputSplit","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapreduce/wrapper/HadoopInputSplit.java","lineNumber":101,"sourceCode":"    private void writeObject(ObjectOutputStream out) throws IOException {\n        // serialize the parent fields and the final fields\n        out.defaultWriteObject();\n\n        // write the input split\n        ((Writable) mapreduceInputSplit).write(out);\n    }\n\n    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {\n        // read the parent fields and the final fields\n        in.defaultReadObject();\n\n        try {\n            Class<? extends Writable> writableSplit = splitType.asSubclass(Writable.class);\n            mapreduceInputSplit =\n                    (org.apache.hadoop.mapreduce.InputSplit)\n                            WritableFactories.newInstance(writableSplit);\n        } catch (Exception e) {\n            throw new RuntimeException(\"Unable to instantiate the Hadoop InputSplit\", e);\n        }\n\n        ((Writable) mapreduceInputSplit).readFields(in);\n    }\n}\n","sourceCodeStart":83,"sourceCodeEnd":107,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapreduce/wrapper/HadoopInputSplit.java#L83-L107","documentation":"Thrown during Java deserialization of the mapreduce-API HadoopInputSplit. readObject() narrows the stored splitType to a Writable subclass and rebuilds the instance via WritableFactories.newInstance(writableSplit). If the class cannot be instantiated (no no-arg constructor, not loadable, not Writable-factory-enabled) the RuntimeException aborts split recovery and the task fails.","triggerScenarios":"Triggered on the TaskManager when a serialized mapreduce HadoopInputSplit is rebuilt and splitType.asSubclass(Writable.class) or WritableFactories.newInstance(writableSplit) throws — e.g. the split class is not on the TaskManager classpath, has no accessible no-arg constructor, or was not registered with a WritableFactory.","commonSituations":"A custom mapreduce InputSplit (Writable) whose class is missing from the shipped jar; split class with no default constructor; class shading/relocation mismatch between client serialization and TaskManager; Hadoop version where the split class changed its factory registration.","solutions":["Ensure the concrete Writable InputSplit class is on the TaskManager classpath via the user-code jar.","Verify the split class has a public no-arg constructor used by WritableFactories.newInstance.","If needed, register a WritableFactory for the split class via WritableFactories.registerFactory(splitClass, factory).","Keep the split class name consistent under any shading so asSubclass/forName resolve at runtime."],"exampleFix":"// before — custom writable split without default constructor\npublic class MySplit extends InputSplit implements Writable {\n    public MySplit(Path p) { ... }\n}\n// after — add no-arg constructor for WritableFactories\npublic class MySplit extends InputSplit implements Writable {\n    public MySplit() {}\n    public MySplit(Path p) { ... }\n}","handlingStrategy":"validation","validationCode":"// Before shipping, verify the split class is a Writable instantiable via WritableFactories\nClass<?> splitType = myMapreduceInputSplit.getClass();\nif (!org.apache.hadoop.io.Writable.class.isAssignableFrom(splitType))\n    throw new IllegalStateException(splitType.getName() + \" is not Writable\");\ntry {\n    Object probe = org.apache.hadoop.io.WritableFactories.newInstance(\n        splitType.asSubclass(org.apache.hadoop.io.Writable.class));\n    if (probe == null) throw new IllegalStateException(\"WritableFactories returned null\");\n} catch (Exception e) {\n    throw new IllegalStateException(\"Cannot instantiate split \" + splitType.getName(), e);\n}","typeGuard":"org.apache.hadoop.io.Writable.class.isAssignableFrom(myMapreduceInputSplit.getClass())","tryCatchPattern":null,"preventionTips":["Ship the user jar containing the concrete Writable split class.","Give custom Writable splits a public no-arg constructor.","Register a WritableFactory for splits that need custom construction.","Keep split class names consistent under shading."],"tags":["hadoop","mapreduce","serialization","classloader","input-split"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}