apache/hadoop · critical · RuntimeException

${theClass.getName()} could not be constructed.

Error message

${theClass.getName()} could not be constructed.

What it means

CallQueueManager.createScheduler reflectively instantiates the class configured under ipc.<port>.scheduler.impl (default FairCallQueueRpcScheduler). It first tries the constructor (int priorityLevels, String ns, Configuration conf). This RuntimeException is thrown from the InvocationTargetException handler: that constructor exists but its body threw, and the original exception is attached as getCause(). (NoSuchMethodException is silently swallowed by `catch (Exception e) {}` and the next signature is tried.)

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/CallQueueManager.java:153

    }

    // Otherwise return default value.
    LOG.info("{} not specified set default value is {}",
        IPC_CALLQUEUE_SERVER_FAILOVER_ENABLE, IPC_CALLQUEUE_SERVER_FAILOVER_ENABLE_DEFAULT);
    return CommonConfigurationKeys.IPC_CALLQUEUE_SERVER_FAILOVER_ENABLE_DEFAULT;
  }

  private static <T extends RpcScheduler> T createScheduler(
      Class<T> theClass, int priorityLevels, String ns, Configuration conf) {
    // Used for custom, configurable scheduler
    try {
      Constructor<T> ctor = theClass.getDeclaredConstructor(int.class,
          String.class, Configuration.class);
      return ctor.newInstance(priorityLevels, ns, conf);
    } catch (RuntimeException e) {
      throw e;
    } catch (InvocationTargetException e) {
      throw new RuntimeException(theClass.getName()
          + " could not be constructed.", e.getCause());
    } catch (Exception e) {
    }

    try {
      Constructor<T> ctor = theClass.getDeclaredConstructor(int.class);
      return ctor.newInstance(priorityLevels);
    } catch (RuntimeException e) {
      throw e;
    } catch (InvocationTargetException e) {
      throw new RuntimeException(theClass.getName()
          + " could not be constructed.", e.getCause());
    } catch (Exception e) {
    }

    // Last attempt
    try {
      Constructor<T> ctor = theClass.getDeclaredConstructor();

View on GitHub (pinned to 2add963021)

Solutions

  1. Read the root cause: the RuntimeException's getCause() holds the actual exception thrown inside your constructor — log/print it before anything else.
  2. Fix the failing code inside the custom scheduler's constructor (usually bad or missing config lookups keyed off ns).
  3. Unit-test the constructor directly with the exact arguments CallQueueManager passes: new MyScheduler(priorityLevels, "ipc.<port>", conf).
  4. As a fallback provide a simpler (int) or no-arg constructor that does not throw.

Example fix

// before
public MyScheduler(int priorityLevels, String ns, Configuration conf) {
  this.weights = conf.getInts(ns + ".weights"); // NPE later if null... or throws here on bad key
}

// after
public MyScheduler(int priorityLevels, String ns, Configuration conf) {
  this.weights = conf.getInts(ns + ".weights");
  if (weights == null || weights.length == 0) {
    this.weights = new int[priorityLevels]; // sane default, do not throw
    Arrays.fill(this.weights, 1);
  }
}
Defensive patterns

Strategy: validation

Validate before calling

// before pointing ipc.<port>.scheduler.impl at it, prove the constructor works:
String ns = "ipc.8020";
int levels = conf.getInt(ns + ".scheduler.priority.levels", 4);
RpcScheduler s = new MyScheduler(levels, ns, conf); // must not throw

Try / catch

try {
  server.start(); // reflective scheduler construction happens here
} catch (RuntimeException e) {
  Throwable root = e.getCause() != null ? e.getCause() : e; // InvocationTargetException cause
  LOG.error("Scheduler construction failed: {}", root, e);
}

Prevention

When it happens

Trigger: A custom RpcScheduler whose (int, String, Configuration) constructor throws — typically an NPE or IllegalArgumentException while reading namespaced configuration keys (e.g., ipc.<port>.scheduler.*) or instantiating its own dependencies; a scheduler class that partially initializes and aborts.

Common situations: Writing a custom IPC scheduler plug-in and testing it on a live RPC server (NameNode/DataNode/ResourceManager ports); typo'd or missing config keys read inside the constructor; constructor expecting a different namespace argument than what CallQueueManager passes.

Related errors


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