Hi Ben,
I don't believe the afterPropertiesSet method on the EhCacheBasedUserCache
class and the EhCacheBasedTicketCache class work as they are intended to.
I noticed that if you refresh the Spring Web context, it messes up the
EhCacheBasedUserCache in the following way: You get: java.lang.IllegalStateException: The ehCacheBasedUserCache
Cache is not alive. When EhCacheBasedUserCache.getUserFromCache is called One very quick way to fix this is to change the
afterPropertiesSet() method in EhCacheBasedUserCache to not remove the cache, and to only create the cache if it
does not exist:
public void afterPropertiesSet() throws Exception {
if (CacheManager.getInstance().cacheExists(CACHE_NAME)) {
// don’t remove the cache
//CacheManager.getInstance().removeCache(CACHE_NAME);
} else {
manager =
CacheManager.create();
// Cache
name, max memory, overflowToDisk, eternal, timeToLive, timeToIdle
cache = new
Cache(CACHE_NAME, Integer.MAX_VALUE, false, false,
minutesToIdle * 60, minutesToIdle * 60);
manager.addCache(cache);
}
} This version works well for me. If you think the
afterPropertiesSet method should re-create the cache if it exists, I believe
that something must be missing. Thanks, Travis Gregg |