{"record":{"id":"d9cec52076cb93b5","repo":"apache/hadoop","slug":"error-in-configuring-object","errorCode":null,"errorMessage":"Error in configuring object","messagePattern":"Error in configuring object","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ReflectionUtils.java","lineNumber":113,"sourceCode":"      Class<?> jobConfClass = \n        conf.getClassByNameOrNull(\"org.apache.hadoop.mapred.JobConf\");\n      if (jobConfClass == null) {\n        return;\n      }\n      \n      Class<?> jobConfigurableClass = \n        conf.getClassByNameOrNull(\"org.apache.hadoop.mapred.JobConfigurable\");\n      if (jobConfigurableClass == null) {\n        return;\n      }\n      if (jobConfClass.isAssignableFrom(conf.getClass()) &&\n            jobConfigurableClass.isAssignableFrom(theObject.getClass())) {\n        Method configureMethod = \n          jobConfigurableClass.getMethod(\"configure\", jobConfClass);\n        configureMethod.invoke(theObject, conf);\n      }\n    } catch (Exception e) {\n      throw new RuntimeException(\"Error in configuring object\", e);\n    }\n  }\n\n  /** Create an object for the given class and initialize it from conf\n   * \n   * @param theClass class of which an object is created\n   * @param conf Configuration\n   * @param <T> Generics Type T.\n   * @return a new object\n   */\n  @SuppressWarnings(\"unchecked\")\n  public static <T> T newInstance(Class<T> theClass, Configuration conf) {\n    return newInstance(theClass, conf, EMPTY_ARRAY);\n  }\n\n  /** Create an object for the given class and initialize it from conf\n   *\n   * @param theClass class of which an object is created","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ReflectionUtils.java#L95-L131","documentation":"ReflectionUtils.configureObject supports the legacy mapred interface org.apache.hadoop.mapred.JobConfigurable: it looks the interface up, and when the object implements it and the Configuration is actually a JobConf, reflectively invokes configure(JobConf). Any failure in that block — the user's configure() throwing (InvocationTargetException), method lookup/access errors, or module-access denial on newer JDKs — is wrapped as RuntimeException(\"Error in configuring object\", e); the real reason is always in getCause().","triggerScenarios":"configureObject(obj, jobConf) where obj's configure(JobConf) throws (a classic NPE on absent config keys); invoking on a class with a mismatched configure signature so getMethod fails; running under a JDK that denies the reflective access.","commonSituations":"Old mapred-API jobs and tools; plugins implementing JobConfigurable whose configure assumes keys that are absent in the new deployment; JDK 17+ module restrictions; users reading only the wrapper message and missing the cause chain.","solutions":["Unwrap the cause: catch RuntimeException and inspect e.getCause() (usually InvocationTargetException around the user's own exception)","Fix the exception thrown inside your configure(JobConf) implementation","Pass a JobConf, not a plain Configuration — the invoke is skipped unless jobConfClass.isAssignableFrom(conf.getClass())","On modern JDKs, run with the Hadoop-documented --add-opens/--add-exports JVM options"],"exampleFix":"// before\ntry {\n  ReflectionUtils.configureObject(tool, conf);\n} catch (RuntimeException e) {\n  throw e; // cause chain lost in logs\n}\n\n// after\ntry {\n  ReflectionUtils.configureObject(tool, conf);\n} catch (RuntimeException e) {\n  Throwable c = e.getCause() != null ? e.getCause() : e;\n  throw new IllegalStateException(\"configure failed for \" + tool.getClass(), c);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { ReflectionUtils.configureObject(tool, jobConf); } catch (RuntimeException e) { Throwable root = e; while (root.getCause() != null) root = root.getCause(); log.error(\"configure failed at {}\", root.toString()); throw new IllegalStateException(\"configuration of \" + tool.getClass() + \" failed\", root); }","preventionTips":["Always walk the cause chain on 'Error in configuring object' before debugging","Unit-test your configure(JobConf) with realistic JobConf contents","Pass JobConf (not plain Configuration) when relying on JobConfigurable","Prefer the Configurable interface over legacy JobConfigurable for new code"],"tags":["hadoop","java","reflection","mapred-api","legacy"],"backgroundTag":"reflection-invocation-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}