title: Apache Shiro EhCache initialization exception: Another unnamed CacheManager already exists in the same VM
body: <p>I am trying to get EhCache configured to handle authorization caching in my Apache Shiro enabled web service. Currently I am getting the following exception:</p>
  <blockquote>
  <p>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:</p>
  </blockquote>
  <ol>
  <li>Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary</li>
  <li>Shutdown the earlier cacheManager before creating new one with same name.</li>
  </ol>
  <p>My shiro.ini looks like:</p>
  <pre><code>[main]   
  ...    
  cacheManager = org.apache.shiro.cache.ehcache.EhCacheManager 
  cacheManager.cacheManagerConfigFile = classpath:ehcache.xml  
  securityManager.cacheManager = $cacheManager 
  </code></pre>
  <p>From this StackOverflow post it looks like people using Spring have gotten around this issue by forcing the CacheManager to be a singleton: <a href="https://stackoverflow.com/questions/10013288/another-unnamed-cachemanager-already-exists-in-the-same-vm-ehcache-2-5">Another unnamed CacheManager already exists in the same VM (ehCache 2.5)</a>.</p>
  <p>Is anybody aware of work-arounds not using Spring initialization (I'm working within the dropwizard framework and have no need to pull in Spring)? Is there some manner of enforcing singleton configuration from the shiro.ini?</p>
  <p>Thank you in advance!</p>