I am creating a simple scala app, and I am using sbt to assemble it and tried to run the jar file I get an error, despite the fact that when I run the script from the ide it works as expected, however, when I try to run it from the jar I get this error:
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
Exception in thread "main" java.lang.ClassCastException: class org.apache.logging.log4j.simple.SimpleLogger cannot be cast to class org.apache.logging.log4j.core.Logger (org.apache.logging.log4j.simple.SimpleLogger and org.apache.logging.log4j.core.Logger are in unnamed module of loader 'app')
Actually, I am confused how is it running as expected when I run the script in the ide but fails in running the jar? also, I don't call the log4j in any of the code scripts, why is it throwing this error?
I even added these couple of lines to build.sbt:
libraryDependencies += "org.apache.logging.log4j" % "log4j-api" % "2.19.0"
libraryDependencies += "org.apache.logging.log4j" % "log4j-core" % "2.19.0"
and did the assembly again, but when I tried to run the jar file again I get the same error, any idea why is this happening and how I can resolve it?
PS: my script uses spark.