apache/hadoop · error · RuntimeException

Error in configuring object

Error message

Error in configuring object

What it means

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().

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ReflectionUtils.java:113

      Class<?> jobConfClass = 
        conf.getClassByNameOrNull("org.apache.hadoop.mapred.JobConf");
      if (jobConfClass == null) {
        return;
      }
      
      Class<?> jobConfigurableClass = 
        conf.getClassByNameOrNull("org.apache.hadoop.mapred.JobConfigurable");
      if (jobConfigurableClass == null) {
        return;
      }
      if (jobConfClass.isAssignableFrom(conf.getClass()) &&
            jobConfigurableClass.isAssignableFrom(theObject.getClass())) {
        Method configureMethod = 
          jobConfigurableClass.getMethod("configure", jobConfClass);
        configureMethod.invoke(theObject, conf);
      }
    } catch (Exception e) {
      throw new RuntimeException("Error in configuring object", e);
    }
  }

  /** Create an object for the given class and initialize it from conf
   * 
   * @param theClass class of which an object is created
   * @param conf Configuration
   * @param <T> Generics Type T.
   * @return a new object
   */
  @SuppressWarnings("unchecked")
  public static <T> T newInstance(Class<T> theClass, Configuration conf) {
    return newInstance(theClass, conf, EMPTY_ARRAY);
  }

  /** Create an object for the given class and initialize it from conf
   *
   * @param theClass class of which an object is created

View on GitHub (pinned to 2add963021)

Solutions

  1. Unwrap the cause: catch RuntimeException and inspect e.getCause() (usually InvocationTargetException around the user's own exception)
  2. Fix the exception thrown inside your configure(JobConf) implementation
  3. Pass a JobConf, not a plain Configuration — the invoke is skipped unless jobConfClass.isAssignableFrom(conf.getClass())
  4. On modern JDKs, run with the Hadoop-documented --add-opens/--add-exports JVM options

Example fix

// before
try {
  ReflectionUtils.configureObject(tool, conf);
} catch (RuntimeException e) {
  throw e; // cause chain lost in logs
}

// after
try {
  ReflectionUtils.configureObject(tool, conf);
} catch (RuntimeException e) {
  Throwable c = e.getCause() != null ? e.getCause() : e;
  throw new IllegalStateException("configure failed for " + tool.getClass(), c);
}
Defensive patterns

Strategy: try-catch

Try / catch

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); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/d9cec52076cb93b5. Report an issue: GitHub.