Issue Details (XML | Word | Printable)

Key: APF-422
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Matt Raible
Reporter: Matt Raible
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
AppFuse

Fix EhCache error messages that resulted from APF-421

Created: 11/Sep/06 10:14 PM   Updated: 07/Mar/07 02:56 AM   Resolved: 07/Mar/07 02:56 AM
Component/s: Persistence Layer
Affects Version/s: 2.0-M2
Fix Version/s: 2.0-M4


 Description  « Hide
From running "mvn" in the web/tapestry project:

[INFO] [talledLocalContainer] WARN - CacheManager.detectAndFixDiskStorePathConflict(271) | Creating a new instance of CacheManager using the diskStorePath "/Users/mraible/Work/appfuse/web/tapestry/target/tomcat5x/container/temp" which is already used by an existing CacheManager.
[INFO] [talledLocalContainer] The source of the configuration was classpath.
[INFO] [talledLocalContainer] The diskStore path for this CacheManager will be set to /Users/mraible/Work/appfuse/web/tapestry/target/tomcat5x/container/temp/ehcache_auto_created_1158030700750.
[INFO] [talledLocalContainer] 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.

Sort Order: Ascending order - Click to sort in descending order
David Bernard added a comment - 30/Oct/06 05:10 PM
Hi folks,

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


Matt Raible added a comment - 01/Nov/06 03:20 PM
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.

Matt Raible added a comment - 23/Jan/07 11:36 PM
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

Dustin Pearce added a comment - 19/Feb/07 05:06 PM
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?

Matt Raible added a comment - 07/Mar/07 02:47 AM
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