{"record":{"id":"6889c96b52361c90","repo":"apache/hadoop","slug":"s03","errorCode":"S03","errorMessage":"Could not load file from classpath [{0}], {1}","messagePattern":"Could not load file from classpath \\[(.+?)\\], (.+?)","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":429,"sourceCode":"   */\n  protected void initLog() throws ServerException {\n    verifyDir(logDir);\n    LogManager.resetConfiguration();\n    File log4jFile = new File(configDir, name + \"-log4j.properties\");\n    if (log4jFile.exists()) {\n      PropertyConfigurator.configureAndWatch(log4jFile.toString(), 10 * 1000); //every 10 secs\n      log = LoggerFactory.getLogger(Server.class);\n    } else {\n      Properties props = new Properties();\n      try {\n        InputStream is = getResource(DEFAULT_LOG4J_PROPERTIES);\n        try {\n          props.load(is);\n        } finally {\n          is.close();\n        }\n      } catch (IOException ex) {\n        throw new ServerException(ServerException.ERROR.S03, DEFAULT_LOG4J_PROPERTIES, ex.getMessage(), ex);\n      }\n      PropertyConfigurator.configure(props);\n      log = LoggerFactory.getLogger(Server.class);\n      log.warn(\"Log4j [{}] configuration file not found, using default configuration from classpath\", log4jFile);\n    }\n  }\n\n  /**\n   * Loads and inializes the server configuration.\n   *\n   * @throws ServerException thrown if the configuration could not be loaded/initialized.\n   */\n  protected void initConfig() throws ServerException {\n    verifyDir(configDir);\n    File file = new File(configDir);\n    Configuration defaultConf;\n    String defaultConfig = name + \"-default.xml\";\n    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/server/Server.java#L411-L447","documentation":"When no <name>-log4j.properties file exists in the config dir, Server.initLog() falls back to loading the bundled default log4j resource from the classpath; if that InputStream load throws IOException, init throws ServerException S03('Could not load file from classpath [httpfs-log4j.properties], <cause>'). This indicates a broken deployment rather than a configuration choice.","triggerScenarios":"Corrupted or truncated hadoop JARs after a partial download/deploy; a repackaged distribution that dropped httpfs's default log4j resource; exotic classloaders (some app servers) that cannot open the resource stream; disk-level read errors.","commonSituations":"Custom 'thin' Docker images stripping 'unused' resources out of JARs; fat-jar/shade plugin relocations that miss resource files; deployment artifacts copied over an unstable network.","solutions":["Verify and redeploy the distribution: compare checksums of the httpfs/hadoop JARs against an official release; a corrupt jar is the usual cause.","If you deliberately repackage, ensure the default log4j properties resource stays on the classpath.","As a workaround, place a valid httpfs-log4j.properties in the HttpFS config dir so the classpath fallback is never used."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# pre-start: bundled default log4j resource must load\nJAR=$(ls /opt/hadoop/share/hadoop/hdfs/httpfs-*.jar | head -1)\nunzip -p \"$JAR\" httpfs-log4j.properties > /dev/null || {\n  echo 'FATAL: default log4j resource missing/unreadable in jar'; exit 1; }\njava -cp \"$JAR\" -e 'System.out.println(ClassLoader.getSystemResource(\"httpfs-log4j.properties\") != null);' 2>/dev/null || true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify distribution checksums after download/copy.","Ship a valid httpfs-log4j.properties in the config dir so the classpath fallback never runs.","Never strip resources from shaded jars without an inventory of what was removed."],"tags":["httpfs","server-startup","classpath","log4j","deployment-corruption"],"backgroundTag":"classpath-resource-load-failure","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}