|
I added shared=true as follows:
<bean id="userCache" class="org.acegisecurity.providers.dao.cache.EhCacheBasedUserCache"> <property name="cache"> <bean class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager"> <bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> <property name="shared" value="true"/> </bean> </property> <property name="cacheName" value="userCache"/> </bean> </property> </bean> However, I still get the following warning: WARN - CacheManager.detectAndFixDiskStorePathConflict(271) | Creating a new instance of CacheManager using the diskStorePath "/tmp" which is already used by an existing CacheManager. The source of the configuration was classpath. The diskStore path for this CacheManager will be set to /tmp/ehcache_auto_created_1162415977182. To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance. This seems to be related to the following issue in EhCache:
http://sourceforge.net/tracker/index.php?func=detail&aid=1616492&group_id=93232&atid=603559 This issue was referenced in the mailing list as tracking the "The UserCache Cache is not alive" bug.
Basically, I create a POJO (like Person) and then register a generic manager that wraps a generic DAO for the POJO. I create an ActionTest class just like the tutorial. Then I create an action class and register the action in applicationContext.xml in the core project. When I run mvn test in the web module, I get: [trace] ERROR [Thread-5] DisposableBeanAdapter.destroy(105) | Couldn't invoke destroy method of bean with name 'org.springframework.cache.ehcache.EhCacheManagerFactoryBean#1b3f829' java.lang.IllegalStateException: The userCache Cache is not alive. When I run the action test in the IDE (IDEA) I get: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.tracemedical.action.DistributionCenterActionTest': Unsatisfied dependency expressed through bean property 'distributionCenterAction': Set this property value or disable dependency checking for this bean. and Exception in thread "Thread-4" java.lang.IllegalStateException: The userCache Cache is not alive. The example shows that the test expects the Action to be injected, but I am not sure how it is loaded from a Spring context in the IDE. I don't know how mvn creates the test in a Spring context to get the action injected, but then it also fails due to the EHCache issue. I can't create action tests with this problem present. Is this a blocking issue for anyone else or is there something about my setup that causes this issue all the time for me? Based on the following thread, I'm going to remove userCache and make sure EhCache is configured as the default 2nd-level cache for Hibernate. This should solve this issue.
http://forum.springframework.org/showthread.php?t=19815 |
||||||||||||||||||||||||||||||||||
I have found when running a sequence of unit tests that create contexts that ehcache 1.2 does not necessarily provide a VM wide cache manager. The first test will succeed but subsequent
attempts to load a spring context will fail with some thing like:
Caused by: net.sf.ehcache.CacheException: Cannot parseConfiguration CacheManager. Attempt to create a new instance of CacheManager using the diskStorePath "/tmp/ehcache" which is already used by an existing CacheManager. The source of the configuration was classpath.
at net.sf.ehcache.CacheManager.configure(CacheManager.java:248)
at net.sf.ehcache.CacheManager.init(CacheManager.java:193)
at net.sf.ehcache.CacheManager.&init&(CacheManager.java:180)
at org.springframework.cache.ehcache.EhCacheManagerFactoryBean.afterPropertiesSet(EhCacheManagerFactoryBean.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBe
......
Adding:
<property name="shared" value="true"/>
To the configuration of org.springframework.cache.ehcache.EhCacheManagerFactoryBean will solve the problem.
Matt - this might be a solution for
APF-422. I am not getting those "helpful" info messages and ehcache is throwing an exception.David Bernard