You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by diffuser <di...@gmail.com> on 2013/10/15 08:00:52 UTC

CacheManager convert error

I use shiro in my web site. My web is SpringMVC+SPring+mybaits.
shiro works well. I don't use cache and there are lots of connection between
web and db. In server console windwo, I find lots of information such as
"2013-10-15 13:43:14,585 INFO [org.apache.shiro.realm.AuthorizingRealm] -
<No cache or cacheManager properties have been 
set.  Authorization cache cannot be obtained.>".

Then I decide to use cache now. In ApplicationContext.xml, I add followed
sentence:
<bean id="cacheManager"
class="org.apache.shiro.cache.ehcache.EhCacheManager" scope="singleton" /

Then the web counldn't be deployed well. It shows error:
BeanPostProcessor before instantiat
ion of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
wit
h name
'org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor#0'
defined in file [E:\develops
oft\Tomcat6\webapps\wscloud\WEB-INF\classes\spring\applicationContext.xml]:
Cannot resolve reference to bean 'securityMa
nager' while setting bean property 'securityManager'; nested exception is
org.springframework.beans.factory.BeanCreation
Exception: Error creating bean with name 'securityManager' defined in file
[E:\developsoft\Tomcat6\webapps\wscloud\WEB-I
NF\classes\spring\applicationContext.xml]: Initialization of bean failed;
nested exception is org.springframework.beans.
factory.BeanCreationException: Error creating bean with name 'cacheManager'
defined in file [E:\developsoft\Tomcat6\weba
pps\wscloud\WEB-INF\classes\spring\applicationContext.xml]: Initialization
of bean failed; nested exception is org.sprin
gframework.beans.ConversionNotSupportedException: Failed to convert property
value of type 'org.apache.shiro.cache.ehcac
he.EhCacheManager' to required type 'net.sf.ehcache.CacheManager' for
property 'cacheManager'; nested exception is java.
lang.IllegalStateException: Cannot convert value of type
[org.apache.shiro.cache.ehcache.EhCacheManager] to required typ
e [net.sf.ehcache.CacheManager] for property 'cacheManager': no matching
editors or conversion strategy found. 

What is wrong ?  I use shiro-all-1.2.2.jar and ehcache-core-2.6.6.jar.





--
View this message in context: http://shiro-user.582556.n2.nabble.com/CacheManager-convert-error-tp7579236.html
Sent from the Shiro User mailing list archive at Nabble.com.

RE: CacheManager convert error

Posted by Michael Chandler <Mi...@onassignment.com>.
I am having the exact same problem.  It's been a real mystery to me for an embarrassingly long time.

Like you, I can get Shiro to work flawlessly during the normal course of development, but the cache management warnings in the logs compel me to do what you've done here, and I get the exact same error.

I have had no luck figuring out what I'm doing wrong here.

Mike

-----Original Message-----
From: diffuser [mailto:diffuser.fuser@gmail.com]
Sent: Monday, October 14, 2013 11:54 PM
To: user@shiro.apache.org
Subject: Re: CacheManager convert error

        <bean id="shirocacheManager"
class="org.apache.shiro.cache.ehcache.EhCacheManager"  scope="singleton" >
                <property name="cacheManagerConfigFile"
value="classpath:ehcache-shiro.xml" />
        </bean>

I change the bean id , then It is ok now.

but after I config the followed information, the new error appear.
        <bean id="securityManager"
class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
                <property name="realm" ref="myRealm" />
                <property name="cacheManager" ref="shirocacheManager" />
        </bean>

the error  is :
Property 'cacheManager' threw exception;  nested exception is org.apache.shiro.cache.CacheException:
net.sf.ehcache.CacheException: Another CacheManager with sam e name 'shiroehcache1' already exists in the same VM.

in ehcache-shiro.xml ,I set the information:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
    name="shiroehcache1">

I only set "shiroehcache1" indeed. what is wrong?



--
View this message in context: http://shiro-user.582556.n2.nabble.com/CacheManager-convert-error-tp7579236p7579238.html
Sent from the Shiro User mailing list archive at Nabble.com.

The information transmitted, including attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this e-mail in error, please notify the sender immediately by replying to the message and deleting the material from your computer.

RE: CacheManager convert error

Posted by Michael Chandler <Mi...@onassignment.com>.
Can you elaborate on what you changed?  What did you change in the web.xml that made this work for you?

-----Original Message-----
From: diffuser [mailto:diffuser.fuser@gmail.com]
Sent: Wednesday, October 16, 2013 11:02 PM
To: user@shiro.apache.org
Subject: Re: CacheManager convert error

Finally I find the reason which cause the issue "nested exception is
org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException:
Another CacheManager with sam e name 'shiroehcache1' already exists in the same VM".

In the web.xml, the xml is invoked twice in either web Context and sping dispatch servlet context.

I changed the web.xml. And cache works well now.




--
View this message in context: http://shiro-user.582556.n2.nabble.com/CacheManager-convert-error-tp7579236p7579271.html
Sent from the Shiro User mailing list archive at Nabble.com.

The information transmitted, including attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this e-mail in error, please notify the sender immediately by replying to the message and deleting the material from your computer.

Re: CacheManager convert error

Posted by diffuser <di...@gmail.com>.
Finally I find the reason which cause the issue "nested exception is
org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException:
Another CacheManager with sam e name 'shiroehcache1' already exists in the
same VM".

In the web.xml, the xml is invoked twice in either web Context and sping
dispatch servlet context.

I changed the web.xml. And cache works well now.




--
View this message in context: http://shiro-user.582556.n2.nabble.com/CacheManager-convert-error-tp7579236p7579271.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: CacheManager convert error

Posted by diffuser <di...@gmail.com>.
	<bean id="shirocacheManager"
class="org.apache.shiro.cache.ehcache.EhCacheManager"  scope="singleton" >
		<property name="cacheManagerConfigFile"
value="classpath:ehcache-shiro.xml" />
	</bean>

I change the bean id , then It is ok now. 

but after I config the followed information, the new error appear.
	<bean id="securityManager"
class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">  
		<property name="realm" ref="myRealm" /> 
		<property name="cacheManager" ref="shirocacheManager" />
	</bean>

the error  is :
Property 'cacheManager' threw exception;
 nested exception is org.apache.shiro.cache.CacheException:
net.sf.ehcache.CacheException: Another CacheManager with sam
e name 'shiroehcache1' already exists in the same VM. 

in ehcache-shiro.xml ,I set the information:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" 
    name="shiroehcache1">

I only set "shiroehcache1" indeed. what is wrong?



--
View this message in context: http://shiro-user.582556.n2.nabble.com/CacheManager-convert-error-tp7579236p7579238.html
Sent from the Shiro User mailing list archive at Nabble.com.