In your ehcache.xml file, does adding a name attribute to the root element help?
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" name="shiro"> Something like that? On the other hand, if you really want a singleton, you can write a EhCacheManagerFactory that implements org.apache.shiro.util.Factory. You'd configure it something like this: ehCacheManager=com.mycompany.MyEhCacheManagerFactory cacheManager = org.apache.shiro.cache.ehcache.EhCacheManager cacheManager.cacheManager=ehCacheManager securityManager.cacheManager = $cacheManager -Jared On Thu 21 Jun 2012 08:15:12 AM CDT, whitneyrzoller wrote: > Hello all, > > I am trying to get EhCache configured to handle authorization caching. > Currently I am getting the following exception: > org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: > Another unnamed CacheManager already exists in the same VM. Please provide > unique names for each CacheManager in the config or do one of following: > 1. Use one of the CacheManager.create() static factory methods to reuse same > CacheManager with same name or create one if necessary > 2. Shutdown the earlier cacheManager before creating new one with same name. > > My shiro.ini looks like: > [main] > ... > cacheManager = org.apache.shiro.cache.ehcache.EhCacheManager > cacheManager.cacheManagerConfigFile = classpath:ehcache.xml > securityManager.cacheManager = $cacheManager > > From this StackOverflow post it looks like people using Spring have gotten > around this issue by forcing the CacheManager to be a singleton > (http://stackoverflow.com/questions/10013288/another-unnamed-cachemanager-already-exists-in-the-same-vm-ehcache-2-5) > > Is anybody aware of work-arounds not using Spring initialization? Is there > some manner of enforcing singleton configuration from the shiro.ini? > > Thank you in advance > > -- > View this message in context: > http://shiro-user.582556.n2.nabble.com/EhCache-initialization-exception-Another-unnamed-CacheManager-already-exists-in-the-same-VM-tp7577532.html > Sent from the Shiro User mailing list archive at Nabble.com.
