java.lang.IllegalAccessError:tried to access field Org.slf4j.impl.StaticLoggerBinder.SINGLETON from class Org.slf4j.LoggerFactory

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.