{"record":{"id":"da4aacd3e5ede0df","repo":"apache/hadoop","slug":"s07","errorCode":"S07","errorMessage":"Could not instanciate service class [{0}], {1}","messagePattern":"Could not instanciate service class \\[(.+?)\\], (.+?)","errorType":"error_code","errorClass":"ServerException","httpStatus":null,"severity":"critical","filePath":"hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/server/Server.java","lineNumber":529,"sourceCode":"   * @param list list of loaded service in order of appearance in the\n   * configuration.\n   *\n   * @throws ServerException thrown if a service class could not be loaded.\n   */\n  private void loadServices(Class[] classes, List<Service> list) throws ServerException {\n    for (Class klass : classes) {\n      try {\n        Service service = (Service) klass.newInstance();\n        log.debug(\"Loading service [{}] implementation [{}]\", service.getInterface(),\n                  service.getClass());\n        if (!service.getInterface().isInstance(service)) {\n          throw new ServerException(ServerException.ERROR.S04, klass, service.getInterface().getName());\n        }\n        list.add(service);\n      } catch (ServerException ex) {\n        throw ex;\n      } catch (Exception ex) {\n        throw new ServerException(ServerException.ERROR.S07, klass, ex.getMessage(), ex);\n      }\n    }\n  }\n\n  /**\n   * Loads services defined in <code>services</code> and\n   * <code>services.ext</code> and de-dups them.\n   *\n   * @return List of final services to initialize.\n   *\n   * @throws ServerException throw if the services could not be loaded.\n   */\n  protected List<Service> loadServices() throws ServerException {\n    try {\n      Map<Class, Service> map = new LinkedHashMap<Class, Service>();\n      Class[] classes = getConfig().getClasses(getPrefixedName(CONF_SERVICES));\n      Class[] classesExt = getConfig().getClasses(getPrefixedName(CONF_SERVICES_EXT));\n      List<Service> list = new ArrayList<Service>();","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/server/Server.java#L511-L547","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the chained cause (ServerException.getCause()) to see the real instantiation failure before changing anything","Give the service class a public no-arg constructor that does not throw","Remove or correct stale class names in the 'httpfs.services'/'httpfs.services.ext' properties","Verify the jar containing the service is on the webapp classpath and built against the running Hadoop/httpfs version"],"exampleFix":"// before\npublic class MyService implements Service {\n  public MyService(Configuration conf) { ... } // only constructor: newInstance() fails\n}\n\n// after\npublic class MyService implements Service {\n  public MyService() { this(new Configuration()); }\n  public MyService(Configuration conf) { ... }\n}","handlingStrategy":"validation","validationCode":"import org.apache.hadoop.lib.server.Server;\nimport org.apache.hadoop.conf.Configuration;\n\n// Preflight: every service class in httpfs.services must have a public no-arg ctor\nfor (String name : config.getStrings(\"httpfs.services\", new String[0])) {\n  Class<?> klass = Class.forName(name.trim());\n  klass.getConstructor(); // throws NoSuchMethodException if no public no-arg ctor\n  klass.asSubclass(org.apache.hadoop.lib.server.Service.class);\n}","typeGuard":null,"tryCatchPattern":"try {\n  server.init();\n} catch (ServerException ex) {\n  if (ex.getError() == ServerException.ERROR.S07) {\n    Throwable cause = ex.getCause(); // real instantiation failure\n    log.error(\"service class failed to instantiate: {}\", cause, ex);\n  }\n  throw ex;\n}","preventionTips":["Keep a public no-arg constructor on every custom Service implementation","Do no real work in constructors - move it to init()","Add a unit test that instantiates every service class you list in httpfs.services","Build custom services against the exact Hadoop/httpfs version you deploy"],"tags":["httpfs","service-loader","reflection","startup","configuration"],"backgroundTag":"service-instantiation-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}