{"record":{"id":"9bae6b0b721da912","repo":"apache/flink","slug":"unable-to-instantiate-hadoop-inputsplit","errorCode":null,"errorMessage":"Unable to instantiate Hadoop InputSplit","messagePattern":"Unable to instantiate 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/mapred/wrapper/HadoopInputSplit.java","lineNumber":119,"sourceCode":"        if (needsJobConf(hadoopInputSplit)) {\n            // the job conf knows how to serialize itself\n            // noinspection ConstantConditions\n            jobConf.write(out);\n        }\n\n        // write the input split\n        hadoopInputSplit.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            hadoopInputSplit =\n                    (org.apache.hadoop.mapred.InputSplit) WritableFactories.newInstance(splitType);\n        } catch (Exception e) {\n            throw new RuntimeException(\"Unable to instantiate Hadoop InputSplit\", e);\n        }\n\n        if (needsJobConf(hadoopInputSplit)) {\n            // the job conf knows how to deserialize itself\n            jobConf = new JobConf();\n            jobConf.readFields(in);\n\n            if (hadoopInputSplit instanceof Configurable) {\n                ((Configurable) hadoopInputSplit).setConf(this.jobConf);\n            } else if (hadoopInputSplit instanceof JobConfigurable) {\n                ((JobConfigurable) hadoopInputSplit).configure(this.jobConf);\n            }\n        }\n\n        hadoopInputSplit.readFields(in);\n    }\n\n    private static boolean needsJobConf(org.apache.hadoop.mapred.InputSplit split) {","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapred/wrapper/HadoopInputSplit.java#L101-L137","documentation":"Thrown during Java deserialization of the mapred-API HadoopInputSplit. On the TaskManager side, readObject() rebuilds the wrapped Hadoop split via WritableFactories.newInstance(splitType), which relies on the split class having a no-arg constructor (or a registered WritableFactory). If the class cannot be instantiated, the deserialization fails and the RuntimeException aborts split recovery, failing the task.","triggerScenarios":"Triggered when Flink ships a serialized HadoopInputSplit to a TaskManager and WritableFactories.newInstance(splitType) throws — e.g. the InputSplit implementation class has no public no-arg constructor, is abstract, or is not visible/loadable by WritableFactories' reflection. The splitType is the concrete class captured at construction on the client.","commonSituations":"A custom mapred InputSplit whose Writable class lacks a default constructor; the split class lives in a user jar that is not shipped to the TaskManagers; Hadoop version mismatch where a split class changed its constructor requirements; a split class that is package-private or lacks the WritableFactory registration Hadoop expects.","solutions":["Ensure the concrete Hadoop InputSplit class is on the TaskManager classpath (ship the user jar with all required classes via the job's user-code jar).","Verify the InputSplit implementation class has a public no-arg constructor, which WritableFactories.newInstance relies on.","If the split is a custom type, register a WritableFactory for it via WritableFactories.registerFactory(splitClass, factory) before the job runs, or extend an existing Hadoop split that is already Writable-factory-enabled.","Confirm the Hadoop dependency version on the cluster matches the one used to build the job."],"exampleFix":"// before — custom split with no default constructor\npublic class MySplit implements Writable {\n    public MySplit(Path p) { ... }\n}\n// after — add a no-arg constructor used by WritableFactories\npublic class MySplit implements Writable {\n    public MySplit() {}\n    public MySplit(Path p) { ... }\n}","handlingStrategy":"validation","validationCode":"// Before shipping the job, verify the concrete split class is instantiable via WritableFactories\nClass<?> splitType = myInputSplit.getClass();\ntry {\n    Object probe = org.apache.hadoop.io.WritableFactories.newInstance(splitType);\n    if (probe == null) throw new IllegalStateException(\"WritableFactories returned null for \" + splitType);\n} catch (Exception e) {\n    throw new IllegalStateException(\"Split class \" + splitType.getName()\n        + \" is not instantiable by WritableFactories (needs public no-arg ctor or registered factory)\", e);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ship the user jar containing the concrete InputSplit class to all TaskManagers.","Give every custom Writable split a public no-arg constructor.","Register a WritableFactory for splits that cannot use the default-constructor path.","Keep the Hadoop version identical across build and cluster."],"tags":["hadoop","mapred","serialization","classloader","input-split"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}