ClassNotFoundException: org.slf4j.LoggerFactory

159,582

Solution 1

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

Solution 2

Better to always download as your first try, the most recent version from the developer's site

I had the same error message you had, and by downloading the jar from the above (slf4j-1.7.2.tar.gz most recent version as of 2012OCT13), untarring, uncompressing, adding 2 jars to build path in eclipse (or adding to classpath in comand line):

  1. slf4j-api-1.7.2.jar
  2. slf4j-simple-1.7.2.jar

I was able to run my program.

Solution 3

For a bit more explanation: keep in mind that the "I" in "api" is interface. The slf4j-api jar only holds the needed interfaces (actually LoggerFactory is an abstract class). You also need the actual implementations (an example of which, as noted above, can be found in slf4j-simple). If you look in the jar, you'll find the required classes under the "org.slf4j.impl" package.

Solution 4

You'll need to download SLF4J's jars from the official site as either a zip (v1.7.4) or tar.gz (v1.7.4)

The download contains multiple jars based on how you want to use SLF4J. If you're simply trying to resolve the requirement of some other library (GWT, I assume) and don't really care about using SLF4J correctly, then I would probably pick the slf4j-api-1.7.4.jar since the Simple jar suggested by another answer does not contain, to my knowledge, the specific class you're looking for.

Solution 5

I got this problem too and I fixed it in this way. I was trying to run mapreduce job locally through Eclipse, after set the configurations, I met this error (in Linux, Virtual Box) To solve it,

  • right click on the project you want to run,
  • go "Properties"->"Java Build Path"->"Add External Jars",
  • then go to file:/usr/lib/Hadoop/client-0.20, choose the three jars named started by "slf4j".

Then you'll be able to run the job locally. Hope my experience will help someone.

Share:
159,582
junaidp
Author by

junaidp

Updated on July 09, 2022

Comments

  • junaidp
    junaidp over 1 year

    I am trying to run GWT RequestFactory and facing this error:

    ClassNotFoundException: org.slf4j.LoggerFactory
    

    I have tried to download slf4j-api-1.3.1.jar but it didnt resolve the issue

    Any idea exactly which jar I need to download ?