Dependency issues with SLF4J - NoClassDefFoundError: org/apache/log4j/or/RendererMap

Viewed 404

I have a Scala application built using sbt 1.2.8. When I try to debug the application in Intellij, I get an error saying

Failed to instantiate SLF4J LoggerFactory
Reported exception:
java.lang.NoClassDefFoundError: org/apache/log4j/or/RendererMap
    at org.apache.log4j.Hierarchy.<init>(Hierarchy.java:97)
    at org.apache.log4j.LogManager.<clinit>(LogManager.java:82)
    ....
caused by: java.lang.ClassNotFoundException: org.apache.log4j.or.RendererMap
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)

I have the following two dependencies included in my libraryDependencies:

"org.slf4j" % "slf4j-log4j12" % "1.7.30"
"org.slf4j" % "slf4j-api" % "1.7.30"

I also have "log4j" % "log4j" % "1.2.17" as a dependency.

I also see the following JARs in the project's External Libraries section:

sbt: org.slf4j:jcl-over-slf4j:1.7.22:jar
sbt: org.slf4j:jul-to-slf4j:1.7.22:jar
sbt: org.slf4j:slf4j-api:1.7.30:jar
sbt: org.slf4j:slf4j-log4j12:1.7.30:jar
sbt: log4j:apache-log4j-extras:1.2.17:jar

(I guess jcl-over-slf4j and jul-to-slf4j are pulled in by some dependencies)

Shouldn't slf4j-log4j12 be sufficient for org/apache/log4j/or/RendererMap?

For the record, I have checked the "include dependencies with Provided scope" option in the application Run/Debug configuration in Intellij. Also, I have excluded log4j-over-slf4j from my Dependencies so as not to cause conflicts in SLF4J, using the following line

libraryDependencies ++= Seq(
    //depencies
).map(_.exclude("org.slf4j","log4j-over-slf4j"))

I tried doing clean and reload from the sbt shell in Intellij, deleting the .idea folder for the project, invalidate cache/restart option, but nothing has worked so far.

0 Answers
Related