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


    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

    使用hbm2java时,使用hibernate-distribution- 3.3.1.GA-dist版本,做好了程序和配置文件后,运行程序出现Exception in thread "main" java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactory错误。



    问题原因:jar文件版本冲突

    类 org.slf4j.impl.StaticLoggerBinder在slf4j-api 中是类的公有静态变量:




    public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();


    而在slf4j-log4j12(slf4j-nop.jar, slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar其中之一)中确是私有变量:



    private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();



    解决方案:1.修改slf的源代码,将这个变量有私有改为公有,再打包,问题可解决。

                      2.slf4j-api.jar 删除,再导入同版本的slf4j-api-1.5.6.jar 和slf4j-log4j12-1.5.6.jar ,问题可解决。

    slf4j-api.jar 在hibernate-distribution-3.3.1.GA-dist/lib/required文件夹下

  • 相关阅读:
    Uva 1636 决斗
    数论初步
    Gym 100169A 最短路
    Uva 12169 不爽的裁判 模运算
    Uva 11582 巨大的斐波那契数 模运算
    Uva 10791 最小公倍数的最小和 唯一分解定理
    Uva 10375 选择与除法 唯一分解定理
    poj 3485 区间选点
    第二届团体程序设计天梯赛
    Uva 12657 双向链表
  • 原文地址:https://www.cnblogs.com/quchengfeng/p/4190199.html
Copyright © 2020-2023  润新知