Home » Java » Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/log4j/Logger in generated jar file

Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/log4j/Logger in generated jar file

Posted by: admin July 12, 2018 Leave a comment

Questions:

I generated a jar file with Maven in IntelliJ IDEA. I get following error message when try to execute it:

Exception in thread “main” java.lang.NoClassDefFoundError:
org/apache/log4j/Logger

I use only one log4j version, 1.2.17 and java version 1.8.0_171. I set skip tests in pom.xml too: <maven.test.skip>true</maven.test.skip>
Execution is successful directly from IDE. I use Maven Surefire plugin:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
            <skipTests>true</skipTests>
        </configuration>
    </plugin>
Answers: