apache/druid · warning
Log4j shutdown was registered in lifecycle but no shutdown…
Error message
Log4j shutdown was registered in lifecycle but no shutdown object exists!
What it means
Log4jShutterDowner.stop() is invoked by the Druid lifecycle on shutdown. It warns when it was registered in the lifecycle but the injected Log4jShutdown instance is null, meaning shutdown logging hooks cannot be flushed. This usually indicates the module's conditional registration and the lifecycle provisioning got out of sync (e.g. a subclassed/overridden binding).
Solutions
- Ensure the standard Log4jShutterDownerModule bindings are intact and no custom module rebinds Log4jShutterDowner without Log4jShutdown
- Check startup logs for the earlier 'Not registering log4j shutdown hooks' warning and fix the underlying log4j classpath problem
- Verify no duplicate Guice modules cause the eager singleton to be created from a different injector stage
Defensive patterns
Strategy: fallback
Validate before calling
if (logManager.getFactory() instanceof Log4jContextFactory) { /* ok */ } else { skip registration; } Type guard
boolean shutdownObjectBound(Injector injector) { try { injector.getInstance(Log4jShutdown.class); return true; } catch (ConfigurationException e) { return false; } } Try / catch
try { lifecycle.stop(); } catch (IllegalStateException e) { LOG.warn("Log4j shutdown object missing; flushing appenders manually", e); LogManager.shutdown(); } Prevention
- Don't override Log4jShutterDownerModule bindings with custom modules
- Keep module registration and lifecycle registration in the same code path
- Grep startup logs for the earlier skip warnings; they precede this failure
When it happens
Trigger: Lifecycle stop() runs with log4jShutdown == null — the Guice binding for Log4jShutdown was not installed (earlier warning path) yet the shutdowner was still provided, or a custom module cleared the binding.
Common situations: Mixed-jar deployments where Log4jShutterDowner is bound eagerly but Log4jShutdown binding was skipped due to class loading issues; custom extension overriding the logging module bindings.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Expected [ ] found [ ]. Unknown class for context factory…
- Not registering log4j shutdown hooks. Not using log4j?
- Shutdown callback registry expected class
- Already closed
- Already closed
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/98521239501efa56.
Report an issue: GitHub.
Appendix: source
Thrown at server/src/main/java/org/apache/druid/initialization/Log4jShutterDownerModule.java:118
public Log4jShutterDowner(Log4jShutdown log4jShutdown)
{
this.log4jShutdown = log4jShutdown;
}
@LifecycleStart
public void start()
{
log.debug("Log4j shutter downer is waiting");
}
@LifecycleStop
public void stop()
{
if (log4jShutdown != null) {
log.debug("Shutting down log4j");
log4jShutdown.stop();
} else {
log.warn("Log4j shutdown was registered in lifecycle but no shutdown object exists!");
}
}
}
}
View on GitHub (pinned to 9b90983fd2)