简体   繁体   中英

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/ProvisionNode

I'm running some very old legacy code, which has worked in the past. This time, it's giving me the following error

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/ProvisionNode

The line that causes the error is

public static org.apache.log4j.Logger getLogger(java.lang.String name) { /* compiled code */ }

in the Logger class defined by log4j. I have log4j 1.2.17 included in the code, which is the most up-to-date version according to maven .

Has anyone else seen this error? Any idea what it could be? Thanks!!

Please note this problem has now been solved, the solution accepted below solves the problem. This is a specific issue with the ProvisionNode class, which is found in only certain log4j libraries. It should be left here and NOT marked as duplicate for others who encounter the same problem.

  1. Download the Apache Logging Jar file
  2. Add the apache-logging-log4j.jar file to your classpath
  3. Clean and build your project.
  4. Run your project

在我的情况下,我忘记从我的 Maven 依赖项中删除<provided>标记,所以它在本地机器上找不到任何东西

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM