Spring 3.1.1 and Cache configuration issue

I'm testing the Spring cache and, this is my context file

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:cache="http://www.springframework.org/schema/cache"
    xsi:schemaLocation=
    "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">

    <cache:annotation-driven cache-manager="simpleCacheManager"/>

    <bean id="simpleCacheManager" class="org.springframework.cache.support.SimpleCacheManager">
        <property name="caches">
            <set>
                <bean class="org.springframework.cache.concurrent.ConcurrentCacheFactoryBean">
                    <property name="name" value="alfresco"/>
                </bean> 
                <bean class="org.springframework.cache.concurrent.ConcurrentCacheFactoryBean">
                    <property name="name" value="alfresco_article"/>
                </bean> 
                <bean class="org.springframework.cache.concurrent.ConcurrentCacheFactoryBean">
                    <property name="name" value="alfresco_action"/>
                </bean>
            </set>
        </property>
    </bean>

I added all required library but, I cannot validate the library because Eclipse still tells me that AOPAlliance.jar and org.springframework.context-3.1.1.RELEASE.jar are missing.

The error is:

Multiple annotations founds at this line: class org.springframework.cache.concurrent.ConcurrentCacheFactoryBean not found.

SOLVED changing to org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean

but, calling the url this happens:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [configuration-context.xml]; nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/config/AopNamespaceUtils
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause

org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [configuration-context.xml]; nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/config/AopNamespaceUtils
    org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)

aop-alliance.jar and org.springframework.aop-3.1.1.RELEASE.jar are both in classpath.

Any clue?

Thanks, Andrea

Answers


Double-check that org.springframework.context-3.1.1.RELEASE.jar is indeed on the classpath. Both Eclipse validation and the error point at this issue.

UPDATE: I've checked, and you are right. ConcurrentCacheFactoryBean seems to be removed since 3.1.0.M1 and is possibly replaced by ConcurrentMapCacheFactoryBean in the same package. I wasn't able to find any proof in the release notes yet. However, if you change the bean class name for your caches to ConcurrentMapCacheFactoryBean, it does seem to work fine.

<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean">
    <property name="name" value="alfresco"/>
</bean> 

UPDATE2: Yes, indeed ConcurrentCacheFactoryBean has been renamed to ConcurrentMapCacheFactoryBean. They just didn't get around to update the tutorial.


Need Your Help

background in header cuts on ipad/iphone and not correctly visible on iphone/ipad working fine on desktop and android

css iphone ipad

I have a problem my website it runs fine on android and desktop but on ipad/iphone my background image seems very large and broken,I have added background-attachment:scroll but still cant fix it.

How to find ID of item to delete in database?

android android-sqlite

Right now I have a database loaded and displayed in a ListView.