Hi Folks --
We've had Spring Security's ACL support running in an application for a while now. While attempting to introduce a caching layer (beyond ACLs) for the application that uses it, I've run into what seems to be a conflict between the org.springframework.security.acls.domain.EhCacheBa sedAclCache implementation and Spring 3.1's (3.1.1 in my case) EhCache provider to support @Cacheable.
After configuring my cacheManager for the application's cache, I was getting an exception telling me that there was already a cacheManager established, and that they need to be unique in order to be wired. Makes perfect sense. I then recalled that Spring Security was also using EhCache to support caching of the ACLs.
What I thought was the (sort of) intelligent thing to do was to change
toCode:<!-- Declare an acl cache--> <bean id="aclCache" class="org.springframework.security.acls.domain.EhCacheBasedAclCache"> <constructor-arg> <bean class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager"> <bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/> </property> <property name="cacheName" value="aclCache"/> </bean> </constructor-arg> </bean>
where "cacheManager2" was the name I had given to the cacheManager I declared to use for the application itself. It seems that Spring Security's constructor is using the normal net.sf EhCacheManager class... a bit of the stacktrace here:Code:<!-- Declare an acl cache--> <bean id="aclCache" class="org.springframework.security.acls.domain.EhCacheBasedAclCache"> <constructor-arg> <bean class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager" ref="cacheManager2"/> <property name="cacheName" value="aclCache"/> </bean> </constructor-arg> </bean>
Code:Caused by: java.lang.IllegalStateException: Cannot convert value of type [org.springframework.cache.ehcache.EhCacheCacheManager] to required type [net.sf.ehcache.CacheManager] for property 'cacheManager': no matching editors or conversion strategy found at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:241) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE] at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:470) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE] ... 63 common frames omitted
I wondered if anyone could point me to any resources that describe how to use these two Spring features together? I can't imagine I'm the first one to try.
I'd appreciate any help!
Matt


Reply With Quote