W
W
web_dev2016-04-12 17:52:30
Java
web_dev, 2016-04-12 17:52:30

Spring CompositeCacheManager of two modules dep.jar and appl.war?

Hello. I have the following situation.
When there is more than one manager in org.springframework.cache.support.CompositeCacheManager, the cache stops working. There is no error, but just empty objects are returned on any request.
If I have only classManager in CompositeCacheManager, then both the application and the cache work, but only for the classManager.
There is dependencyEE.jar in which the cache is defined.

<cache:annotation-driven/>

<bean id="eManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"
    p:cache-manager-ref="eCache" />

<bean id="eCache"
    class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
    p:config-location="classpath:/META-INF/eEhcache.xml"
    p:cacheManagerName="${service.name}.En" p:acceptExisting="false" p:shared="true"/>

There is an application.war which also defines a cache and a cache manager that takes the manager from war and jar.
For example, you can see it from javamelody, but it doesn't work. I just get empty objects back. How to fix? I've been trying for two days now
<cache:annotation-driven cache-manager="cacheManager"/>
<bean id="classManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"
    p:cache-manager-ref="classCache" />

<bean id="classCache"
    class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
    p:config-location="classpath:ehcache.xml" p:cacheManagerName="${service.name}.Class"
    p:acceptExisting="false" />


<bean id="cacheManager" class="org.springframework.cache.support.CompositeCacheManager">
    <property name="cacheManagers">
        <array>
            <ref bean="classManager" />
            <ref bean="eManager" /> 
        </array>
    </property>
    <property name="fallbackToNoOpCache" value="true" />
</bean>

annotation.spring.codesolution.site/79749-3446-usi... - Tried variations but to no avail...
Where is my mistake? Thanks for the hints.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question