apache/hadoop · critical · ServerException

S07

S07

Error message

Could not instanciate service class [{0}], {1}

What it means

HttpFS Server instantiates every service class listed in the 'httpfs.services' and 'httpfs.services.ext' configuration properties via reflection (Class.newInstance()) during startup. Error S07 ('Could not instanciate service class') is thrown when instantiating one of those classes fails with any exception other than a ServerException, and the original exception is chained as the cause. Typical root causes are a missing public no-arg constructor, an abstract class, or a constructor/static initializer that throws.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/server/Server.java:529

   * @param list list of loaded service in order of appearance in the
   * configuration.
   *
   * @throws ServerException thrown if a service class could not be loaded.
   */
  private void loadServices(Class[] classes, List<Service> list) throws ServerException {
    for (Class klass : classes) {
      try {
        Service service = (Service) klass.newInstance();
        log.debug("Loading service [{}] implementation [{}]", service.getInterface(),
                  service.getClass());
        if (!service.getInterface().isInstance(service)) {
          throw new ServerException(ServerException.ERROR.S04, klass, service.getInterface().getName());
        }
        list.add(service);
      } catch (ServerException ex) {
        throw ex;
      } catch (Exception ex) {
        throw new ServerException(ServerException.ERROR.S07, klass, ex.getMessage(), ex);
      }
    }
  }

  /**
   * Loads services defined in <code>services</code> and
   * <code>services.ext</code> and de-dups them.
   *
   * @return List of final services to initialize.
   *
   * @throws ServerException throw if the services could not be loaded.
   */
  protected List<Service> loadServices() throws ServerException {
    try {
      Map<Class, Service> map = new LinkedHashMap<Class, Service>();
      Class[] classes = getConfig().getClasses(getPrefixedName(CONF_SERVICES));
      Class[] classesExt = getConfig().getClasses(getPrefixedName(CONF_SERVICES_EXT));
      List<Service> list = new ArrayList<Service>();

View on GitHub (pinned to 2add963021)

Solutions

  1. Read the chained cause (ServerException.getCause()) to see the real instantiation failure before changing anything
  2. Give the service class a public no-arg constructor that does not throw
  3. Remove or correct stale class names in the 'httpfs.services'/'httpfs.services.ext' properties
  4. Verify the jar containing the service is on the webapp classpath and built against the running Hadoop/httpfs version

Example fix

// before
public class MyService implements Service {
  public MyService(Configuration conf) { ... } // only constructor: newInstance() fails
}

// after
public class MyService implements Service {
  public MyService() { this(new Configuration()); }
  public MyService(Configuration conf) { ... }
}
Defensive patterns

Strategy: validation

Validate before calling

import org.apache.hadoop.lib.server.Server;
import org.apache.hadoop.conf.Configuration;

// Preflight: every service class in httpfs.services must have a public no-arg ctor
for (String name : config.getStrings("httpfs.services", new String[0])) {
  Class<?> klass = Class.forName(name.trim());
  klass.getConstructor(); // throws NoSuchMethodException if no public no-arg ctor
  klass.asSubclass(org.apache.hadoop.lib.server.Service.class);
}

Try / catch

try {
  server.init();
} catch (ServerException ex) {
  if (ex.getError() == ServerException.ERROR.S07) {
    Throwable cause = ex.getCause(); // real instantiation failure
    log.error("service class failed to instantiate: {}", cause, ex);
  }
  throw ex;
}

Prevention

When it happens

Trigger: Server startup while iterating the classes from 'httpfs.services'/'httpfs.services.ext'; klass.newInstance() throws InstantiationException (abstract class, interface, no no-arg constructor), IllegalAccessException (non-public constructor), ExceptionInInitializerError (static block failed), or any exception from the service's default constructor.

Common situations: Deploying a custom httpfs service whose only constructor takes arguments; a constructor that reads missing configuration and throws; a jar compiled against an incompatible Hadoop version so static initializers fail; a stale class name left in httpfs.services after a package refactor.

Related errors


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