Java. Lang. illegalaccesserror: tried to access field org. slf4j. impl. staticloggerbinder. Singleton from class org. slf4j. loggerfactory
When using hbm2java, using the hibernate-distribution-3.3.1.GA-dist version, after the program and configuration file is completed, the running program appears exception in thread "Main"Java. Lang. illegalaccesserror: tried to access field org. slf4j. impl. staticloggerbinder. Singleton from class org. slf4j. loggerfactoryError.
Cause: JAR file version conflict
Class org. slf4j. impl. staticloggerbinder is the public static variable of the class in the slf4j-api:
Public static final staticloggerbinder Singleton = new staticloggerbinder (); |
And in slf4j-log4j12 (slf4j-nop.jar, slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or one of the logback-classic.jar) is indeed a private variable:
Private Static final staticloggerbinder Singleton = new staticloggerbinder (); |
Solution: 1. Modify the SLF source code, change the variable private to public, and then package it. The problem can be solved.
2. Remove the slf4j-api.jar and then import the slf4j-api-1.5.6.jar and slf4j-log4j12-1.5.6.jar of the same version. The problem can be solved.
The slf4j-api.jar is in the hibernate-distribution-3.3.1.GA-dist/lib/required folder