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

來源:互聯網
上載者: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

使用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檔案夾下

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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.