First, the problem description:
Use Hibernate-distribution-3.3.1.ga-dist and slf4j-1.7.7 when setting up hibernate environments. After the configuration file and the program OK, the following issues occur with the running program:
1java.lang.IllegalAccessError:tried to access field Org.slf4j.impl.StaticLoggerBinder.SINGLETON fromclassorg.slf4j.LoggerFactory2At Org.slf4j.loggerfactory.<clinit> (loggerfactory.java:60)3At Org.hibernate.cfg.configuration.<clinit> (configuration.java:151)4At Com.pers.test.customertest.<clinit> (customertest.java:33)5 At Sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)6At Sun.reflect.NativeConstructorAccessorImpl.newInstance (nativeconstructoraccessorimpl.java:62)7At Sun.reflect.DelegatingConstructorAccessorImpl.newInstance (delegatingconstructoraccessorimpl.java:45)8At Java.lang.reflect.Constructor.newInstance (constructor.java:423)9At Org.junit.runners.BlockJUnit4ClassRunner.createTest (blockjunit4classrunner.java:217)TenAt Org.junit.runners.blockjunit4classrunner$1.runreflectivecall (blockjunit4classrunner.java:266) OneAt Org.junit.internal.runners.model.ReflectiveCallable.run (reflectivecallable.java:12) AAt Org.junit.runners.BlockJUnit4ClassRunner.methodBlock (blockjunit4classrunner.java:263) -At Org.junit.runners.BlockJUnit4ClassRunner.runChild (blockjunit4classrunner.java:78) -At Org.junit.runners.BlockJUnit4ClassRunner.runChild (blockjunit4classrunner.java:57) theAt Org.junit.runners.parentrunner$3.run (parentrunner.java:290) -At Org.junit.runners.parentrunner$1.schedule (parentrunner.java:71) -At Org.junit.runners.ParentRunner.runChildren (parentrunner.java:288) -At org.junit.runners.parentrunner.access$000 (parentrunner.java:58) +At Org.junit.runners.parentrunner$2.evaluate (parentrunner.java:268) -At Org.junit.runners.ParentRunner.run (parentrunner.java:363) +At Org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (junit4testreference.java:86) AAt Org.eclipse.jdt.internal.junit.runner.TestExecution.run (testexecution.java:38) atAt Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:459) -At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:675) -At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (remotetestrunner.java:382) -At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (remotetestrunner.java:192)
Second, cause analysis: Jar Package version Conflict
Class Org.slf4j.impl.StaticLoggerBinder in hibernate-distribution-3.3.1.ga-dist\hibernate-distribution-3.3.1.ga\ Lib\required\slf4j-api-1.5.2.jar is the public static variable of the class:
Public Static Final New Staticloggerbinder ();
In Slf4j-1.7.7\slf4j-log4j12-1.7.7.jar , it is a private variable:
Private Static Final New Staticloggerbinder ();
Solution: 1. Modify the source code of the SLF, change the variable from private to public, then package, the problem can be resolved.
2. Replace the Slf4j-api-1.5.2.jar with the Slf4j-1.7.7\slf4j-api-1.7.7.jar, the problem is resolved.
Third, the jar package drawings
If annotations are required or integrated with other frameworks, they are imported separately, and the jar functions are no longer mentioned.
java.lang.IllegalAccessError:tried to access field Org.slf4j.impl.StaticLoggerBinder.SINGLETON from class Org.slf4j.LoggerFactory