{"record":{"id":"4918b77d57cf45f1","repo":"apache/beam","slug":"unable-to-create-inputformat-object","errorCode":null,"errorMessage":"Unable to create InputFormat object: ","messagePattern":"Unable to create InputFormat object: ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"critical","filePath":"sdks/java/io/hadoop-format/src/main/java/org/apache/beam/sdk/io/hadoop/format/HadoopFormatIO.java","lineNumber":843,"sourceCode":"                      .getClassByName(conf.get().get(\"mapreduce.job.inputformat.class\"))\n                      .getConstructor()\n                      .newInstance();\n          /*\n           * If InputFormat explicitly implements interface {@link Configurable}, then setConf()\n           * method of {@link Configurable} needs to be explicitly called to set all the\n           * configuration parameters. For example: InputFormat classes which implement Configurable\n           * are {@link org.apache.hadoop.mapreduce.lib.db.DBInputFormat DBInputFormat}, {@link\n           * org.apache.hadoop.hbase.mapreduce.TableInputFormat TableInputFormat}, etc.\n           */\n          if (Configurable.class.isAssignableFrom(inputFormatObj.getClass())) {\n            ((Configurable) inputFormatObj).setConf(conf.get());\n          }\n        } catch (InstantiationException\n            | IllegalAccessException\n            | ClassNotFoundException\n            | NoSuchMethodException\n            | InvocationTargetException e) {\n          throw new IOException(\"Unable to create InputFormat object: \", e);\n        }\n      }\n    }\n\n    @VisibleForTesting\n    InputFormat<?, ?> getInputFormat() {\n      return inputFormatObj;\n    }\n\n    @VisibleForTesting\n    void setInputFormatObj(InputFormat<?, ?> inputFormatObj) {\n      this.inputFormatObj = inputFormatObj;\n    }\n\n    @Override\n    public Coder<KV<K, V>> getOutputCoder() {\n      return KvCoder.of(keyCoder, valueCoder);\n    }","sourceCodeStart":825,"sourceCodeEnd":861,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/hadoop-format/src/main/java/org/apache/beam/sdk/io/hadoop/format/HadoopFormatIO.java#L825-L861","documentation":"HadoopFormatIO reflectively instantiates the configured InputFormat class (via the job configuration). If reflection fails — class missing, instantiation error, illegal access, wrong constructor, or constructor threw — it wraps the cause in this IOException.","triggerScenarios":"The `inputFormatClass` configuration points to a class that is not on the classpath, is abstract/an interface, has no no-arg constructor, or whose constructor throws; triggered from computeSplitsIfNecessary(), createReader(), or testReadingWithConfigurableInputFormat().","commonSituations":"Hadoop client jars not shaded/ bundled in the Beam pipeline; typo in the fully-qualified InputFormat class name; InputFormat lacking a public no-arg constructor; conflicting Hadoop versions (e.g. class exists in two jars with incompatible signatures).","solutions":["Confirm the InputFormat class name in the configuration is correct and fully qualified","Ensure the Hadoop InputFormat and its dependencies are bundled in the classpath (shadowJar / job staging)","Verify the class is concrete and has a public no-arg constructor","Check for Hadoop version conflicts (mvn dependency:tree) and align hadoop-client versions"],"exampleFix":"// before\nconf.set(\"mapreduce.job.inputformat.class\", \"com.example.MyIF\");\n// after\nconf.set(\"mapreduce.job.inputformat.class\", \"com.example.MyInputFormat\"); // verify class is on classpath","handlingStrategy":"validation","validationCode":"try {\n  Class<?> cls = Class.forName(conf.get(\"mapreduce.job.inputformat.class\"));\n  cls.getDeclaredConstructor().newInstance();\n} catch (ReflectiveOperationException e) {\n  throw new IllegalStateException(\"InputFormat not loadable/instantiable: \" + e, e);\n}","typeGuard":"static boolean isValidInputFormatClass(String name) {\n  try {\n    Class<?> c = Class.forName(name);\n    return InputFormat.class.isAssignableFrom(c)\n        && !c.isInterface()\n        && !java.lang.reflect.Modifier.isAbstract(c.getModifiers())\n        && java.util.Arrays.stream(c.getConstructors()).anyMatch(ctor -> ctor.getParameterCount() == 0);\n  } catch (ClassNotFoundException e) { return false; }\n}","tryCatchPattern":"try {\n  pipeline.run().waitUntilFinish();\n} catch (Exception e) {\n  if (e.getCause() instanceof IOException && e.getCause().getMessage().startsWith(\"Unable to create InputFormat object\")) {\n    throw new IllegalStateException(\"Check InputFormat class name and classpath bundling\", e);\n  }\n  throw e;\n}","preventionTips":["Run mvn dependency:tree to confirm hadoop-client is present once, without conflicts","Use the shadowJar plugin so Hadoop InputFormat classes ship with the pipeline jar","Smoke-test Class.forName(inputFormatClassName) in a unit test before launching the pipeline"],"tags":["hadoop","reflection","class-not-found","inputformat"],"backgroundTag":"class-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}