开发者社区> 问答> 正文

Hibernate整合EHCACHE报错?报错

最近在用springside4时,在台式机上没有问题,但是在我笔记本上就有问题了,抛出异常是:

net.sf.ehcache.CacheException: 
Error configuring from null. Initial cause was null

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/schemas/spring-core.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build EntityManagerFactory

Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build EntityManagerFactory

Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.spi.CacheImplementor]



Caused by: org.hibernate.cache.CacheException: net.sf.ehcache.CacheException: Error configuring from null. Initial cause was null

Caused by: net.sf.ehcache.CacheException: Error configuring from null. Initial cause was null
不知道是什么问题

展开
收起
爱吃鱼的程序员 2020-06-22 22:23:54 513 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    看起来是ehcache配置文件报的错。有两个可能:

    1,没找到ehcache.xml

    2,ehcache配置文件中缺少了某个对象的配置

    重点看下第二项。

    纠结了很久,最后把所有的缓存配置文件放到src下面,台式机和笔记本都不报错了。匪夷所思的很,现在正常了。

    不才,请大家过来看看:

    @红薯 @Java_lilin @微名喝喝 @喵了个咪 @缪斯的情人 @yangzhiyong @zb0423 @swanky_yao @沙漠雄鹰  @阿咪 @zhangyou1010 @SuperEric @JavaGG @丛俊龙  @liueric @lwei @024 @sunnynie @TWmelody @张英泽 @神勇小白鼠 @zb0423 @Evensunny @龙凯 @枫凌渡 @宋浩 @鉴客 @整俩硬菜 @kevinwang168 @虫虫

    这个错误是 Spring的吧

    Errorcreatingbeanwithname'entityManagerFactory'definedinServletContextresource[/WEB-INF/schemas/spring-core.xml]:错误挺明显了!

    对的,问题很明显。关键是我在台式机上没有问题,放到笔记本上有问题。我家里面的笔记本式华硕的K40和东芝的。都报这个错误,放到家里面的台式机也没有错。这就是很大的问题了。

    引用来自“红薯”的答案

    这个错误是 Spring的吧
    你是不是配置文件有问题,看异常既有spring的也有hibernate的,应该是读取相关配置文件失败了

    引用来自“缪斯的情人”的答案

    你是不是配置文件有问题,看异常既有spring的也有hibernate的,应该是读取相关配置文件失败了

    引用来自“FortaleOpenSource”的答案

    引用来自“缪斯的情人”的答案

    你是不是配置文件有问题,看异常既有spring的也有hibernate的,应该是读取相关配置文件失败了回复 @缪斯的情人:肯定是匹配的,用intellijIDEA创建项目的是侯会让你选择JDK的路径的,netbeans在安装的时候就会检测jdk的路径。其实我最疑惑的是为何台式机不报错,这个不知道是不是个问题。回复 @缪斯的情人:出来公司的是netbeans外,其他的都是jetbrainsintellijIDEA回复 @FortaleOpenSource:用什么IDE来吗,比如eclipse的编译环境complier和你的jdk版本匹配吗我觉得跟编译环境没有多大的关系,华硕笔记本装的是jdk6,东芝和台式机装的是jdk7,今天我放到公司的笔记本上也是报这个错误,公司的笔记本式联想的,win764jdk6。 <?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:jpa="http://www.springframework.org/schema/data/jpa"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:cache="http://www.springframework.org/schema/cache"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.1.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.1.xsdhttp://www.springframework.org/schema/data/jpahttp://www.springframework.org/schema/data/jpa/spring-jpa.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsdhttp://www.springframework.org/schema/cachehttp://www.springframework.org/schema/cache/spring-cache-3.1.xsd"default-lazy-init="true"><context:property-placeholderignore-unresolvable="true"location="/WEB-INF/application.properties"/><context:component-scanbase-package="org.wb.demo"><context:exclude-filtertype="annotation"expression="org.springframework.stereotype.Controller"/></context:component-scan><!--数据源配置,使用DBCP数据库连接池--><beanid="dataSource"class="org.apache.commons.dbcp.BasicDataSource"destroy-method="close"><!--ConnectionInfo--><propertyname="driverClassName"value="${jdbc.driver}"/><propertyname="url"value="${jdbc.url}"/><propertyname="username"value="${jdbc.username}"/><propertyname="password"value="${jdbc.password}"/><!--ConnectionPoolingInfo--><propertyname="maxActive"value="${dbcp.maxActive}"/><propertyname="maxIdle"value="${dbcp.maxIdle}"/><propertyname="defaultAutoCommit"value="false"/><!--连接Idle一个小时后超时--><propertyname="timeBetweenEvictionRunsMillis"value="3600000"/><propertyname="minEvictableIdleTimeMillis"value="3600000"/></bean><!--JpaEntityManager配置--><beanid="entityManagerFactory"class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"><propertyname="dataSource"ref="dataSource"/><propertyname="jpaVendorAdapter"ref="hibernateJpaVendorAdapter"/><propertyname="packagesToScan"value="org.wb.demo"/><propertyname="jpaProperties"><props><propkey="hibernate.hbm2ddl.auto">update</prop><propkey="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop><propkey="net.sf.ehcache.configurationResourceName">cache/ehcache-local.xml</prop><propkey="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop></props></property></bean><beanid="hibernateJpaVendorAdapter"class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"><propertyname="databasePlatform"><beanfactory-method="getDialect"class="org.wb.demo.db.DbUtils"><constructor-argref="dataSource"/></bean></property></bean><jpa:repositoriesbase-package="org.wb.demo"transaction-manager-ref="transactionManager"entity-manager-factory-ref="entityManagerFactory"/><beanid="transactionManager"class="org.springframework.orm.jpa.JpaTransactionManager"><propertyname="entityManagerFactory"ref="entityManagerFactory"/></bean><tx:annotation-driventransaction-manager="transactionManager"proxy-target-class="true"/><beanid="validator"class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/><cache:annotation-drivencache-manager="ehCacheManager"/><beanid="ehCacheManager"class="org.springframework.cache.ehcache.EhCacheCacheManager"><propertyname="cacheManager"ref="ehcache"/></bean><beanid="ehcache"class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"><propertyname="configLocation"value="classpath:ehcache.xml"/></bean></beans>那位大神有SSH集成ehcache的实例啊,求指教
    2020-06-23 11:51:46
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载