You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by Michael Chandler <Mi...@onassignment.com> on 2013/07/08 23:37:56 UTC

RE: CacheManager error

Does anyone have experience setting up EhCache via Spring?  I'm still struggling with the issues below and would appreciate any insight that anyone has.

Best,

Mike

From: Michael Chandler [mailto:Michael.Chandler@onassignment.com]
Sent: Friday, June 28, 2013 11:49 AM
To: user@shiro.apache.org
Subject: CacheManager error

I was hoping someone might have some insight into an issue I'm having...

I'm using Spring to manage Shiro config and I'm attempting to set up EhCache for session management for my web application.  I'm getting the following error:

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.
The source of the existing CacheManager is: InputStreamConfigurationSource [stream=java.io.ByteArrayInputStream@29989e7c]

I didn't follow any Spring specific documentation regarding my configuration cache management.  Instead, I tried to carve my own path by reading the docs specific to shiro.ini configuration and came up with this for my applicationContext.xml:

<bean id="shiroSessionDao" class="org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO" scope="singleton" />
<bean id="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager" scope="singleton" />

<bean id="shiroSessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
                <property name="sessionDAO" ref="shiroSessionDao" />
</bean>

<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
                <property name="realm" ref="oaiRealm" />
                <property name="sessionManager" ref="shiroSessionManager" />
                <property name="cacheManager" ref="cacheManager" />
</bean>

Eventually, the securityManager bean is referenced in the shiroFilter bean.  However, the error I'm getting leads me to believe that I'm not going down the right path in how I've set up the relationships above.

Can anyone assist me?

Mike