Java.Lang.Noclassdeffounderror: Org.Slf4J.Loggerfactory

ClassNotFoundException: org.slf4j.LoggerFactory

Try downloading jar from here

You can find, it holds the class you need.

EDIT

Seems like the website has changed its structure. You need to choose which jar file you need for your project.

For slf4j-api jar file for latest version as of now, please visit this link

For slf4j-simple jar file for latest version as of now, please visit this link

NoClassDefFoundError: org/slf4j/Logger

The answer is hidden in the manual page:

Use of the Log4j 2 SLF4J Binding (log4j-slf4j-impl-2.0.jar) together
with the SLF4J adapter (log4j-to-slf4j-2.0.jar) should never be
attempted, as it will cause events to endlessly be routed between
SLF4J and Log4j 2.

You want to keep the log4j-slf4j-impl-2.xx.jar and remove the log4j-to-slf4j-2.xx.jar.

Slf4j and Logback error: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory

I think that your generated jar file doesn't contain your dependencies.

To add dependencies in the generated jar file, I use maven-assembly-plugin maven plugin

<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>**your main class**</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>

I hope it works for you

Error java.lang.ClassNotFoundException: org.slf4j.LoggerFactory when trying to execute the jar

Simple: the classpath that you are using when trying to execute your JAR file does not contain the required sl4j logger library.

That is all there is to this. This is not about your build setup - it is about the setup that gets used when you run java on the command line!

See here for further reading.

java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory even though I have the right dependencies

The classloader of your apache/tomcat(catalina) don't find the LoggerFactory by reflection, mybe this caused by the multitude of logging dependencies that was in your classpath.

please try to REMOVE this from your POM

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.3</version>
</dependency>

And replace it just with

<dependency>
<groupId><org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.22</version>
</dependency>

I hope that will work for you.



Related Topics



Leave a reply



Submit