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文件夹下

时间: 2024-10-25 19:52:48

java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactory的相关文章

java.lang.IllegalAccessError: tried to access method org.apache.commons.codec.digest.DigestUtils.getDigest(Ljava/lang/String;)Ljava/security/MessageDigest; from class com.xyb.mis.pay.jingdong.util.Sig

严重: Servlet.service() for servlet [springmvc] in context with path [/xyb-mis-web] threw exception [Handler processing failed; nested exception is java.lang.IllegalAccessError: tried to access method org.apache.commons.codec.digest.DigestUtils.getDige

java.lang.IllegalAccessError: class com.google.protobuf.HBaseZeroCopyByteString

hadoop mr 或者 spark 操作 hbase时候就出现这个错误 这是hbase的bug,可在jira上看到该问题:https://issues.apache.org/jira/browse/HBASE-10304 报错信息: 15/08/17 19:28:33 ERROR yarn.ApplicationMaster: User class threw exception: org.apache.hadoop.hbase.DoNotRetryIOException: java.lang

java.lang.SecurityException: Can't make field constructor accessible

原本使用GsonConvertor,在Android版本5.1.1上没有任何问题,结果切换到版本6.0.1上,出现以下所示问题: java.lang.IllegalArgumentException: Unable to create converter for java.util.List<model> ,StackOverFlow有个帖子谈这个问题http://stackoverflow.com/questions/34315499/unable-to-create-converter-f

Android Xposed框架出现java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation问题

第一次玩Xposed框架,按照多个demo的格式写了一个demo发现死活不进入 public abstract void handleLoadPackage(LoadPackageParam lpparam) throws Throwable; 方法,去/data/data/de.robv.android.xposed.installer/log/error.log查看,发现crash了 Loading modules from /data/app/com.example.xposed-1.ap

Xposed出现 java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation

Xposed出现 java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation的解决方法 第一次在Xposed的框架下编写模块,在官方给的tutorial上就出现了问题,也安装好了就是不出效果,查看exposed的日志后天报出一堆错误,开头是 java.lang.IllegalAccessError: Class ref in pre-verified cla

【异常】java.lang.IllegalArgumentException: Cannot locate declared field class org.apache.http.impl.client.HttpClientBuilder.dnsResolver 的解决方案

起因:使用htmlunit爬取外部网页的时候遇到这个异常:java.lang.IllegalArgumentException: Cannot locate declared field class org.apache.http.impl.client.HttpClientBuilder.dnsResolver <dependency> <groupId>net.sourceforge.htmlunit</groupId> <artifactId>html

java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementatio

错误信息: java.lang.IllegalAccessError: Class ref inpre-verified class resolved to unexpected implementatio 发生场景:在动态加载APK.jar的时候 错误分析:这种一般是引用重复(也就是你现在的APK和你要加载的APK.Jar之间有重复的引用),像在我的项目中遇到的问题就是:被加载的apk选择的最低版本在4.0以下,需要引用 android.support.v7.app.ActionBarActi

【转】Xposed出现 java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation

Xposed出现 java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation的解决方法 第一次在Xposed的框架下编写模块,在官方给的tutorial上就出现了问题,也安装好了就是不出效果,查看exposed的日志后天报出一堆错误,开头是 java.lang.IllegalAccessError: Class ref in pre-verified cla

日志异常:java.lang.NoClassDefFoundError: Could not initialize class org.slf4j.impl.StaticLoggerBinder

今天启动开发的项目,碰到了一个日志上的bug:java.lang.NoClassDefFoundError: Could not initialize class org.slf4j.impl.StaticLoggerBinder.刚看到一脸懵.于是到网上查了一下,也有遇到类似问题的.说是要加一些依赖,但是我试了不起作用.后来看到了一篇讲slf4j集成logback和log4j的文章,给我了我灵感,尝试了一下,解决了问题.文章的地址:https://www.jianshu.com/p/9a283