java.lang.ClassNotFoundException: org.apache.log4j.Logger
Closed this issue · 7 comments
While running code in local mode from Intellij, I am getting below issue
Main class : com.yotpo.metorikku.Metorikku
VM options : -Dspark.master=local[*] -Dspark.executor.cores=1 -Dspark.driver.bindAddress=127.0.0.1 -Dspark.serializer=org.apache.spark.serializer.KryoSerializer
Program Arguments : -c examples/movies.yaml
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
i encountered the same problem, can you tell me how you solved it
Hi @etcxy !
So I'm thinking it happens from time to time due to hive-jdbc bringing some bad libraries (PR to fix this coming soon).
Add the following to your build.sbt:
lazy val excludeLog4j = ExclusionRule(organization = "org.apache.logging.log4j")
lazy val excludeParquet = ExclusionRule(organization = "org.apache.parquet")
"org.apache.hive" % "hive-jdbc" % "2.3.3" % "provided" excludeAll(excludeNetty, excludeNettyAll, excludeLog4j, excludeParquet)
Hi @lyogev
I also got same issue and I saw that those lines which you mentioned is already added in built.sbt. But still facing the same issue. Can you please help me regarding that.
Guys, did anyone find the solution for this issue?
@aksashu000 Does this happen with the latest version?
yes
i solve it
with adding
"org.apache.hive" % "hive-jdbc" % "2.3.3" % "provided" excludeAll(excludeNetty, excludeNettyAll, excludeLog4j, excludeParquet)
and checklist at you application configuration include dependencies with "Provided" scope