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

见下面问题:

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.现在问题终于弄清楚了,在网上找了相关问题的解决方法,很多都是与包有关,但是遇到这种问题还是第一次。做一个标记,下次遇到类似问题切记仔细。

你可能感兴趣的:(java,tomcat,Hibernate,.net,Access)