简体   繁体   English

无法为休眠4.1.1配置EhCache,因为它抛出“ net / sf / ehcache / CacheException”

[英]Not able to configure EhCache for hibernate 4.1.1 as it throws “ net/sf/ehcache/CacheException”

<!--Cache Provider-->
     <property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property> 
     <property name="hibernate.cache.use_second_level_cache">true</property> 
    <!--The Query-level Cache-->
    <property name="hibernate.cache.use_query_cache">true</property>

These are the properties i defined in hibernate.cfg.xml. 这些是我在hibernate.cfg.xml中定义的属性。 When I used the similar way in hibernate 3 versions it worked but in 4.1.1 hibernate it is throwing " net/sf/ehcache/CacheException". 当我在hibernate 3版本中使用类似的方法时,它可以工作,但是在4.1.1 hibernate中,它抛出“ net / sf / ehcache / CacheException”。 I have included hibernate-ehcache-4.1.1 jar also. 我也包括了hibernate-ehcache-4.1.1 jar。 I even tried adding the ehcache 2.8 jar. 我什至尝试添加ehcache 2.8 jar。 Still each addition adds to the list of errors. 仍然每个添加添加到错误列表。 Please help me. 请帮我。

The stacktrace is below... stacktrace在下面...

java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.getConstructor(Class.java:1657)
at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:386)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:251)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2273)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2269)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1738)
at com.gau.dbaccess.HibernateUtilities.<clinit>(HibernateUtilities.java:31)
at com.gau.dbaccess.ComponentsDetailsAccess.resetOnlinePsdLockAfterServerStart(ComponentsDetailsAccess.java:3503)
at com.gau.controller.ApplicationContextController.contextInitialized(ApplicationContextController.java:132)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1637)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)

Caused by: java.lang.ClassNotFoundException: net.sf.ehcache.CacheException at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) ... 26 more Jan 8, 2014 3:40:07 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Error listenerStart Jan 8, 2014 3:40:07 PM org.apache.catalina.core.StandardContext startInternal 由以下原因引起:java.lang.ClassNotFoundException:org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)处的net.sf.ehcache.CacheException在org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader。 java:1559)at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)...更多26 Jan 2014年1月8日下午3:40:07 org.apache.catalina.core.StandardContext startInternal SEVERE:错误listenerStart Jan 8 ,2014 3:40:07 PM org.apache.catalina.core.StandardContext startInternal

Probably you are mixing hibernate3 and hibernate4 stuff. 可能您正在混合hibernate3和hibernate4的东西。
Remove all old hibernate3 code and classes; 删除所有旧的hibernate3代码和类; if you are using spring use org.springframework.orm.hibernate4.LocalSessionFactoryBean (check package, must be the hibernate4 one) 如果您使用的是Spring,请使用org.springframework.orm.hibernate4.LocalSessionFactoryBean (检查包,必须为hibernate4之一)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM