Bug: Failed to instantiate SLF4J LoggerFactory in Cassandra 3.11.12
Status: Resolved
Priority: Normal
Resolution: Fixed
Created: 23/Mar/22 11:01
Resolved: 31/Mar/22 12:24

After upgrading to 3.11.12, Cassandra crashes on startup because of a class that cannot be found in slf4j.

{code}

Failed to instantiate SLF4J LoggerFactory
Reported exception:
java.lang.NoClassDefFoundError: org/slf4j/event/LoggingEvent
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetPublicMethods(Class.java:2902)
    at java.lang.Class.getMethods(Class.java:1615)
    at ch.qos.logback.core.joran.util.beans.BeanDescriptionFactory.create(BeanDescriptionFactory.java:35)
    at ch.qos.logback.core.joran.util.beans.BeanDescriptionCache.getBeanDescription(BeanDescriptionCache.java:47)
    at ch.qos.logback.core.joran.util.PropertySetter.<init>(PropertySetter.java:68)
    at ch.qos.logback.core.joran.action.NestedComplexPropertyIA.isApplicable(NestedComplexPropertyIA.java:65)
    at ch.qos.logback.core.joran.spi.Interpreter.lookupImplicitAction(Interpreter.java:233)
    at ch.qos.logback.core.joran.spi.Interpreter.getApplicableActionList(Interpreter.java:252)
    at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:142)
    at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:128)
    at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:165)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:152)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:110)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
    at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:65)
    at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:140)
    at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
    at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
    at org.slf4j.LoggerFactory.bind(LoggerFactory.java:129)
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:302)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:276)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:288)
    at org.apache.cassandra.service.CassandraDaemon.<clinit>(CassandraDaemon.java:117)
Caused by: java.lang.ClassNotFoundException: org.slf4j.event.LoggingEvent
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
    ... 27 more
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/event/LoggingEvent
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetPublicMethods(Class.java:2902)
    at java.lang.Class.getMethods(Class.java:1615)
    at ch.qos.logback.core.joran.util.beans.BeanDescriptionFactory.create(BeanDescriptionFactory.java:35)
    at ch.qos.logback.core.joran.util.beans.BeanDescriptionCache.getBeanDescription(BeanDescriptionCache.java:47)
    at ch.qos.logback.core.joran.util.PropertySetter.<init>(PropertySetter.java:68)
    at ch.qos.logback.core.joran.action.NestedComplexPropertyIA.isApplicable(NestedComplexPropertyIA.java:65)
    at ch.qos.logback.core.joran.spi.Interpreter.lookupImplicitAction(Interpreter.java:233)
    at ch.qos.logback.core.joran.spi.Interpreter.getApplicableActionList(Interpreter.java:252)
    at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:142)
    at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:128)
    at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:165)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:152)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:110)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
    at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:65)
    at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:140)
    at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
    at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
    at org.slf4j.LoggerFactory.bind(LoggerFactory.java:129)
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:302)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:276)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:288)
    at org.apache.cassandra.service.CassandraDaemon.<clinit>(CassandraDaemon.java:117)
Caused by: java.lang.ClassNotFoundException: org.slf4j.event.LoggingEvent
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
    ... 27 more

{code}

It seems like the version of logback introduced in https://issues.apache.org/jira/browse/CASSANDRA-17204 requires a more up to date version of slf4j-api.jar than what is currently shipped with Cassandra (see https://www.slf4j.org/codes.html#log4j_version).

Replacing the shipped version (1.7.7) with the most recent 1.7.X (1.7.36 at the time of this writing) seemingly solves the problem.