java.lang.IllegalAccessError:tried to access field org.slf4j.impl.Static.
java.lang.IllegalAccessError:tried to access field Org.slf4j.impl.StaticLoggerBinder.SINGLETON from class Org.slf4j.LoggerFactory
When using Hbm2java, the hibernate-distribution-3.3.1.ga-dist version is used, the program and configuration files are completed, and the running program appears exception in thread "main" java.lang.IllegalAccessError:tried to access field Org.slf4j.impl.StaticLoggerBinder.SINGLETON from class Org.slf4j.LoggerFactory error.
Problem cause: Jar file version conflict
Class Org.slf4j.impl.StaticLoggerBinder is the public static variable of a class in 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 Logback-classic.jar one of them) is indeed a private variable:
private static final Staticloggerbinder SINGLETON = new Staticloggerbinder ();
Solution: 1. Modify the source code of the SLF, change the variable private to public, then package, the problem can be resolved.
2.slf4j-api.jar Delete, and then import the same version of Slf4j-api-1.5.6.jar and Slf4j-log4j12-1.5.6.jar, the problem can be resolved.
Slf4j-api.jar under the Hibernate-distribution-3.3.1.ga-dist/lib/required folder
java.lang.IllegalAccessError:tried to access field Org.slf4j.impl.StaticLoggerBinder.SINGLETON from class Org.slf4j.LoggerFactory