【问题标题】:Ehcache element <cache/> does not allow attribute "transactionalMode"?Ehcache 元素 <cache/> 不允许属性“transactionalMode”?
【发布时间】:2015-09-15 03:07:08
【问题描述】:

根据Ehcache documentation,从2.0版本开始,一个Ehcache缓存可以根据元素&lt;cache/&gt;上属性transactionalMode的值参与JTA事务。

如果是这样,那为什么Ehcache,当它在我的Ehcache配置文件中遇到这个属性时,会抛出以下异常并抱怨“元素不允许属性“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" />

【问题讨论】:

  • 对我来说很好。你确定你的类路径中有 ehcache v2+ 吗?也许你偶然有两个版本,也许你的 Hibernate 依赖包含了一个?
  • 斯卡夫曼,你是对的!与 Ehcache 集成的 Hibernate 3.3.2.GA 已包含 Ehcache 1.2.3,我明确包含 Ehcache 2.1.0(然后是 2.2.0)。您是否知道 Hibernate 的哪个版本支持(需要)Ehcache 2.0 或更高版本?
  • 另外,我怎样才能阻止 Maven 包含 Ehcache 1.2.3,而是将 Ehcache 2.2.0 与 Hibernate Ehcache 3.3.2GA(取决于 Ehcache 1.2.3)或 3.5.1-Final(取决于在 Ehcache 1.5.0 上)?随意将您的 cmets 放入您对我的问题的回答中。
  • 我已将第二条评论中的问题提升为 stackoverflow.com/questions/3561235/… 上的问题。

标签: configuration transactions ehcache


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    这意味着您需要删除传递依赖 ehcache 1.2.3.jar 并保留 include 2.X version 。需要看看这是否与hibernate 3.2.X一起工作没有问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-23
      • 2016-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-21
      • 2018-03-22
      • 2014-05-23
      相关资源
      最近更新 更多