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


I’m working on a simple Java application where I’m not using any mayor framework, just maven for building and dependency management, Lombok to avoid boilerplate and sfl4j and Logback for logging duties. When I run the application directly trough IntelliJ IDE, it works perfect, but when I try to run the maven generated jar file from the command line, I’m getting the error java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory.

My maven pom looks as follows:


Any idea?


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

          <mainClass>**your main class**</mainClass>

I hope it works for you

Answered By – Ahmed HENTETI

Answer Checked By – David Marino (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published