I am trying to configure EhCache to handle authorization caching in my web service that supports Apache Shiro. I am currently getting the following exception:
org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: another unnamed CacheManager already exists in the same virtual machine. Specify unique names for each CacheManager in the config or do one of the following:
1. Use one of the static methods factory CacheManager.create () static to reuse the same CacheManager with the same name or create it if necessary.
2. Close the previous cacheManager before creating a new one with the same name.
My shiro.ini looks like this:
[Home]
...
cacheManager = org.apache.shiro.cache.ehcache.EhCacheManager cacheManager.cacheManagerConfigFile = classpath: ehcache.xml
securityManager.cacheManager = $ cacheManager
From this StackOverflow post, it seems that people using Spring have circumvented this issue by causing CacheManager to be single: Another unnamed CacheManager already exists in the same virtual machine (ehCache 2.5) .
Does anyone know of workarounds that don't use Spring initialization (I work in the framework of dropwizard and don't need to pull Spring in)? Is there any way to provide a singleton configuration from the shiro.ini file?
Thank you in advance!
apache shiro ehcache
Whitney Zoller Jun 21 2018-12-12T00: 00Z
source share