Home » Java » java – Gradle: Failed to instantiate SLF4J LoggerFactory error-Exceptionshub

java – Gradle: Failed to instantiate SLF4J LoggerFactory error-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

As I mentioned in title, projects on my local which are using Gradle started to throw this error:

This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/6.2/userguide/gradle_daemon.html
Process command line: /Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home/bin/java -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country=GB -Duser.language=en -Duser.variant -cp /Users/loaner/.gradle/wrapper/dists/gradle-6.2-bin/6xuflze0i9mjovrm0ys9asj72/gradle-6.2/lib/gradle-launcher-6.2.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.2
Please read the following process output to find out more:
-----------------------
Failed to instantiate SLF4J LoggerFactory
Reported exception:
java.lang.NoClassDefFoundError: ch/qos/logback/core/joran/spi/JoranException
    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)
    at org.gradle.api.logging.Logging.getLogger(Logging.java:38)
    at org.gradle.launcher.daemon.bootstrap.DaemonMain.<clinit>(DaemonMain.java:62)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:58)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
    at org.gradle.launcher.daemon.bootstrap.GradleDaemon.main(GradleDaemon.java:22)
Caused by: java.lang.ClassNotFoundException: ch.qos.logback.core.joran.spi.JoranException
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 14 more
java.lang.ExceptionInInitializerError
    at org.gradle.internal.classloader.ClassLoaderUtils.tryClose(ClassLoaderUtils.java:52)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:64)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
    at org.gradle.launcher.daemon.bootstrap.GradleDaemon.main(GradleDaemon.java:22)
Caused by: java.lang.IllegalStateException: org.slf4j.LoggerFactory in failed state. Original exception was thrown EARLIER. See also http://www.slf4j.org/codes.html#unsuccessfulInit
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:422)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
    at org.gradle.internal.concurrent.CompositeStoppable.<clinit>(CompositeStoppable.java:37)
    ... 4 more

-----------------------
Check the JVM arguments defined for the gradle process in:
 - gradle.properties in project root directory

And I cannot figure out how to solve it.

What I have tried so far;

IntelliJ IDEA 2019.3.3 (Community Edition)
java version “1.8.0_221”

How to&Answers:

This looks like you have an invalid Gradle installation.

Assuming you are using the Gradle wrapper, I would remove the content of $HOME/.gradle/wrapper/dists/gradle-<gradle-version> and try again with running the project.

If you are not using the Gradle wrapper, but an installed version, I would remove it and re-install.