Ehcache元素<cache>不允许属性“transactionalMode”?</cache>

时间:2010-08-24 20:15:15

标签: configuration transactions ehcache

根据Ehcache documentation,从版本2.0开始,Ehcache缓存可以根据元素transactionalMode上的属性<cache/>的值参与JTA事务。< / p>

如果这是真的,那么为什么Ehcache在我的Ehcache配置文件中遇到此属性时会抛出以下异常并抱怨“Element不允许属性”transactionalMode“。”:

Caused by: net.sf.ehcache.CacheException: Error configuring from zip:C:/Program Files/Oracle/Middleware/user_projects/domains/abstrack1/servers/AdminServer/tmp/_WL_user/_appsdir_middleware-ear-1.0-SNAPSHOT_ear/n8rga7/middleware-ejb-1.0-SNAPSHOT.jar!/ehcache.xml. Initial cause was Error configuring from input stream. Initial cause was null:35: Element <cache> does not allow attribute "transactionalMode".
    at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:95)
    at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:131)
    at net.sf.ehcache.CacheManager.parseConfiguration(CacheManager.java:241)
    at net.sf.ehcache.CacheManager.init(CacheManager.java:190)
    at net.sf.ehcache.CacheManager.<init>(CacheManager.java:183)
    at net.sf.ehcache.hibernate.EhCacheProvider.start(EhCacheProvider.java:128)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:183)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1291)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
    ... 76 more]]>

以下是我的ehcache.xml文件中的示例缓存定义,其中我将transactionalMode设置为“xa”:

<cache
    name="com.db.spgit.abstrack.model.Security"
    maxElementsInMemory="500"
    eternal="false"
    timeToIdleSeconds="300"
    timeToLiveSeconds="86400"
    overflowToDisk="false"
    transactionalMode="xa" />

2 个答案:

答案 0 :(得分:3)

事实证明,Maven还在我的项目EAR文件中包含了Ehcache 1.2.3,因为Hibernate Ehcache Integration 3.3.2.GA需要Ehcache 1.2.3。

答案 1 :(得分:0)

这意味着您需要删除传递依赖关系ehcache 1.2.3.jar并保留include 2.X版本。需要看看是否在使用hibernate 3.2.X时没有问题。