Log4j and kotlin-compiler-1.3.11.jar : java.lang.NoSuchMethodError: org.apache.log4j.Level.toLevel


#1

I am using (in gradle):

compile “log4j:log4j:1.2.17”
compile “org.jetbrains.kotlin:kotlin-compiler:1.3.11”

and i have dependency-hell-error:

Exception in thread “main” java.lang.NoSuchMethodError: org.apache.log4j.Level.toLevel(Ljava/lang/String;Lorg/apache/log4j/Level;)Lorg/apache/log4j/Level;
at org.apache.log4j.helpers.OptionConverter.toLevel(OptionConverter.java:198)
at org.apache.log4j.xml.DOMConfigurator.parseLevel(DOMConfigurator.java:663)
at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:536)
at org.apache.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.java:436)
at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:1004)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:872)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:778)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)
at org.apache.log4j.LogManager.(LogManager.java:127)
at org.slf4j.impl.Log4jLoggerFactory.(Log4jLoggerFactory.java:66)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)

Because kotlin-developers have include into “kotlin-compiler-1.3.11.jar” the following classes:

org/apache/log4j/Level.class
org/apache/log4j/Priority.class

witch is incompatible with new versions of log4j and generates dependency hell.

Why did you do it? And what i need do to fix this problem? No. Trouble! Very BIG TROUBLE!

Why?


#2

Have you tried using kotlin-compiler-embeddable instead of kotlin-compiler? It has its dependencies shadowed and thus should not cause such problem.


#3

Reference issue: https://youtrack.jetbrains.com/issue/KT-19312


#4

Now, i am using kotlin-compiler-embeddable - it is work OK. Thank you very much.