NoClassDefFoundError: logging LogFactory解决

2025-09-30 18:06:24

1、java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

at net.sf.ehcache.CacheManager.<clinit>(CacheManager.java:65)

at org.hibernate.cache.EhCacheProvider.start(EhCacheProvider.java:131)

at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.start(RegionFactoryCacheProviderBridge.java:72)

at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:221)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)

at com.gis520.sessionFactory.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:31)

at com.gis520.test.EmpTest.testSelect(EmpTest.java:22)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)

at org.junit.runners.ParentRunner.run(ParentRunner.java:236)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory

at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

at java.lang.ClassLoader.loadClass(ClassLoader.java:252)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

... 30 more

1、出现以上的异常是由于缺少一个commons-logging的jar包,commons-logging.jar包的作用可以说是和Log4j.jar类似,都是对日记处理等。但是工程里边已经有了log4j.jar了还是报这个错,我也纳闷,是一定需要commons-logging.jar包吧。。小编也是初学者,待得知答案再告诉大家。或者大家知道答案的评论一下哦。一起学习。网上下载一个commons-logging。jar包

NoClassDefFoundError: logging LogFactory解决

2、将包拷贝到工程的lib文件下——》add to build path

NoClassDefFoundError: logging LogFactory解决

3、添加好后运行程序即可发现解决了异常、

NoClassDefFoundError: logging LogFactory解决

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢