{"record":{"id":"6fc7b7c3b23203fb","repo":"apache/hadoop","slug":"failed-to-initialize-s","errorCode":null,"errorMessage":"Failed to initialize %s","messagePattern":"Failed to initialize (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSAudit.java","lineNumber":160,"sourceCode":"  /**\n   * Create a collection of KMSAuditLoggers from configuration, and initialize\n   * them. If any logger failed to be created or initialized, a RunTimeException\n   * is thrown.\n   */\n  private void initializeAuditLoggers(Configuration conf) {\n    Set<Class<? extends KMSAuditLogger>> classes = getAuditLoggerClasses(conf);\n    Preconditions\n        .checkState(!classes.isEmpty(), \"Should have at least 1 audit logger.\");\n    for (Class<? extends KMSAuditLogger> c : classes) {\n      final KMSAuditLogger logger = ReflectionUtils.newInstance(c, conf);\n      auditLoggers.add(logger);\n    }\n    for (KMSAuditLogger logger: auditLoggers) {\n      try {\n        LOG.info(\"Initializing audit logger {}\", logger.getClass());\n        logger.initialize(conf);\n      } catch (Exception ex) {\n        throw new RuntimeException(\n            \"Failed to initialize \" + logger.getClass().getName(), ex);\n      }\n    }\n  }\n\n  private void logEvent(final OpStatus status, AuditEvent event) {\n    event.setEndTime(Time.now());\n    for (KMSAuditLogger logger: auditLoggers) {\n      logger.logAuditEvent(status, event);\n    }\n  }\n\n  /**\n   * Logs to the audit service a single operation on the KMS or on a key.\n   *\n   * @param opStatus\n   *          The outcome of the audited event\n   * @param op","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSAudit.java#L142-L178","documentation":"After KMS instantiates every configured audit logger (KMSAudit.java:160, initializeAuditLoggers), it calls initialize(conf) on each. Any exception thrown by a logger's initialize is wrapped in RuntimeException 'Failed to initialize <logger class name>' and aborts KMS startup. The inner cause carries the real reason, e.g. HdfsKMSAuditLogger failing to acquire the NameNode audit logger.","triggerScenarios":"Configuring hadoop.kms.audit.logger with a logger whose initialize() fails: HdfsKMSAuditLogger when the HDFS audit logger cannot be initialized (bad log4j/HDFS audit config), or a custom logger whose constructor/initialize throws for missing settings.","commonSituations":"Enabling HDFS-based KMS audit logging without the required HDFS audit log4j configuration; custom logger expecting extra properties in kms-site.xml that were not deployed; logger jar present but its runtime dependencies missing; version mismatch between logger implementation and KMS API.","solutions":["Read the full stack trace: the caused-by exception names the real failure inside the logger's initialize()","For HdfsKMSAuditLogger, ensure the HDFS audit logger configuration it depends on is present and valid on the KMS host","Add/fix any properties your custom logger requires in kms-site.xml before enabling it","As a stopgap, temporarily remove the failing logger from hadoop.kms.audit.logger to bring KMS back up, fix the cause, then re-enable"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Startup-time failure: read the caused-by of RuntimeException 'Failed to initialize <logger>' and fix the logger's own config before restart","preventionTips":["Validate custom loggers in staging with the same kms-site.xml","Ensure logger runtime dependencies are on the KMS classpath","Have a rollback config (property removed) to bring KMS up quickly"],"tags":["hadoop-kms","configuration","audit","startup-failure","initialization"],"backgroundTag":"plugin-initialization-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}