Caused By: java.lang.NoClassDefFoundError: org/apache/log4j/Logger

During runtime your application is unable to find the jar.

Taken from this answer by Jared:

It is important to keep two different exceptions straight in our head
in this case:

  1. java.lang.ClassNotFoundException This an Exception, it indicates that the
    class was not found on the classpath. This indicates that we were
    trying to load the class definition, and the class did not exist on
    the classpath.

  2. java.lang.NoClassDefFoundError This is Error, it indicates that the JVM
    looked in its internal class definition data structure for the
    definition of a class and did not find it. This is different than
    saying that it could not be loaded from the classpath. Usually this
    indicates that we previously attempted to load a class from the
    classpath, but it failed for some reason – now we’re trying again,
    but we’re not even going to try to load it, because we failed
    loading it earlier. The earlier failure could be a
    ClassNotFoundException or an ExceptionInInitializerError (indicating
    a failure in the static initialization block) or any number of other
    problems. The point is, a NoClassDefFoundError is not necessarily a
    classpath problem.

for similarities and differences

Leave a Comment