Spring2.5 配置Hibernate3.3 EhCache 配置错误解决方法

本文记录了一次因EhCache版本不一致导致的初始化错误,分析了问题原因,并分享了解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

见下面问题:

Invocation of init method failed; nested exception is java.lang.IllegalAccessError: tried to access method net.sf.ehcache.CacheManager.<init>(Ljava/net/URL;)V from class org.hibernate.cache.EhCacheProvider


2010-04-10 16:47:54 [main:6484] - [ERROR] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [E:\help\soft\tomcat\tomcat-5.5\webapps\wyw\WEB-INF\classes\applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalAccessError: tried to access method net.sf.ehcache.CacheManager.<init>(Ljava/net/URL;)V from class org.hibernate.cache.EhCacheProvider
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1337)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)

从这面的问题看,是因为配置EhCache错误,找到源码后,调试发现,有的类没有引进来,仔细查看是发现,原来我导入lib下的类为ehcache-1.2.3.jar,而现在调用的类却是来自与Hibernate 3.1 Core Liberries引用lib下的ehcache 1.1.jar.现在问题终于弄清楚了,在网上找了相关问题的解决方法,很多都是与包有关,但是遇到这种问题还是第一次。做一个标记,下次遇到类似问题切记仔细。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值