configuration - Ehcache 元素 <cache/> 不允许属性 "transactionalMode"?

标签 configuration transactions ehcache

根据Ehcache documentation ,从2.0版本开始,Ehcache缓存可能会参与JTA基于属性值的交易transactionalMode在元素 <cache/> .

如果这是真的,那么为什么Ehcache在我的Ehcache配置文件中遇到这个属性时,会抛出以下异常并提示“Element does not allowed attribute ‘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" />

最佳答案

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

关于configuration - Ehcache 元素 <cache/> 不允许属性 "transactionalMode"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3560659/

相关文章:

java - struts中如何消除空指针异常?

spring - 如何将(@Autowired)@Service注入(inject)ConstraintValidator?

android - 从 AsyncTask 的事务访问 Firebase 数据库

mysql - 想要在以下程序中应用交易,但它不起作用

java - 如何在 EHCache 实例中使用元素版本控制?

EhCache 未找到序列化程序

java - 使用 Ehcache 扩展 Java Web 应用程序

php - 为 Symfony MicroKernel 注册自定义配置命名空间

java - Java中处理复杂配置的最佳方法

java - 如何立即获取 ManagedService 配置?