Announcement Announcement Module

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions ( project, this forum has been decommissioned in favour of Spring Extensions one at:

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Costin Leau
SpringSource - Spring Training, Consulting, and Support - "From the Source"
See more
See less
Declarative Caching Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Originally posted by johanhammar View Post

    We're also affected by this problem in our project. Is there another solution for this or do we have to load all caching in the security context?


    Johan Hammar
    I ran into this post and also experienced the same issue. I had a web.xml that uses <context-param> to load up different xmls for data, service, security...etc and I found that the cache configuration needs to be place AFTER the intended cache beans are configured.

    So, I put my cache config (cache-service.xml) as the last file to be loaded in contextConfigLocation and everything is working.

    PHP Code:


    • #17
      Flushing Single Object

      Originally posted by RShelley View Post
      So after playing with Declarative Caching, the first thing that I notice is that the Flushing Model flushes the entire cache. I see in the file that there is a method for "onRemoveFromCache" which removes a single object from the cache, however, I don't see an interface for doing so. It seems all-or-nothing. I'm sure there's a way to get it to remove one object at a time and not just flush the entire cache, but I haven't come across it yet.
      I second this. Any points on how to approach flushing single object from cache?


      • #18
        I am one of the authors of a new project intended to provide Ehcache integration for Spring 3 projects via annotations:

        We are excited to announce the general availability of the first production release, 1.0.1.

        This release provides 2 method-level annotations in the spirit of Spring’s @Transactional:


        When appropriately configured in your Spring application, this project will create caching aspects at runtime around your @Cacheable annotated methods.

        Usage documentation can be found on the project wiki:


        • #19
          Hi edalquist,

          I am using spring 3.0 AOP to implement OSCache. But I am getting Spring meta data attributes exception as meta data class is not there in spring3.0-core jar while it was there in 2.5. I included spring-core 2.5.6.jar and after that it is not throwing exception but caching is not happening. If EHCache configuration is working fine with spring 3.0 , i am ok to implement it. But I am not getting any good documentation which gives all steps. Could you please guide on it?

          Following is the configuration/code I am using.
          <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns=""
          xmlns:xsi="" xmlns:oscache=""


          <oscache:config configLocation=""/>

          <oscache:annotations providerId="cacheProvider">
          <oscache:caching id="testCaching" groups="pb_test" cronExpression="*/30 * * *" refreshPeriod="864000"/>
          <oscache:flushing id="testFlushing" groups="pb_test"/>






          @Cacheable(modelId = "testCaching")
          public HashMap<String,String> getAllGlobalVariables()
          HashMap<String,String> hm = new HashMap<String,String>();
          hm.put("test1", "test1");
          hm.put("test2", "test2");
          hm.put("PUB_PASSWORD_EXPIRE", "30");
          return hm;

          Cache Log :-

          16 May 2010 22:52:16,587 DEBUG [] AbstractCacheAdministrator - Constructed AbstractCacheAdministrator()
          16 May 2010 22:52:16,587 INFO [] GeneralCacheAdministrator - Constructed GeneralCacheAdministrator()
          16 May 2010 22:52:16,587 INFO [] GeneralCacheAdministrator - Creating new cache
          16 May 2010 22:52:23,438 DEBUG [] Config - OSCache: Config called
          16 May 2010 22:52:23,438 DEBUG [] AbstractCacheAdministrator - Constructed AbstractCacheAdministrator()
          16 May 2010 22:52:23,438 INFO [] GeneralCacheAdministrator - Constructed GeneralCacheAdministrator()
          16 May 2010 22:52:23,438 INFO [] GeneralCacheAdministrator - Creating new cache


          • #20
            I tried to implement new google project for ehcache.
            But I am getting the problems there too as below.

            Hitting URL http://ehcache-spring-annotations.go...ehcache-spring is not giving any xsd file which is giving an error

            org.springframework.beans.factory.parsing.BeanDefi nitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://ehcache-spring-annotations.go...hcache-spring]

            Also it is giving an error with 1.0.2 jar as below. it is trying to look for spring-ehcache.xsd while in the jar ehcache-spring.xsd available.

            [DEBUG,PluggableSchemaResolver] Couldn't find XML schema [http://ehcache-spring-annotations.go...ring-1.0.xsd]: class path resource [com/googlecode/ehcache/annotations/spring-ehcache-1.0.xsd]
   class path resource [com/googlecode/ehcache/annotations/spring-ehcache-1.0.xsd] cannot be opened because it does not exist


            • #21
              There was a bug in that version of the library. Also please use our bug tracker and email list linked off of to get a much more prompt response. Nick and I only check these forums periodically.


              • #22
                Declarative caching with Tangosol

                Hello All,

                I have done enough searching for my issue related to declarative caching services using Spring but had no luck.

                Based on the article [] I have configured my Spring beans to use coherence declaratively. Adopting pre-bean configuration approach, my service calls a dao and which in-turn calls the target bean.

                My App context has following entries:

                <bean id="entityCacheProvider" class="org.springmodules.cache.provider.tangosol.C oherenceFacade" />
                <coherence:config failQuietly="true" serializableFactory="XSTREAM"/>
                <bean id="entityrDaoTarget" class="">
                <property name="sessionFactory" ref="sessionFactoryEntity"/>
                <coherenceroxy id="entityDao" refId="entityDaoTarget">
                <coherence:caching methodName="findEntityQuery" cacheName="entityQueryCache" />
                <bean id="entityService" class="com.service.entity.entityServiceImpl">
                <property name="entityDao" ref="entityDao"/>

                I have tested these configuration in two ways:
                1) I am loading this context in JUnit and testing method findEntityQuery(Map, Map) in service layer (which calls dao findEntityQuery(Map,Map) method), it is caching properly. My test case is very simple, I am calling findEntityQuery(Map, Map) in a loop, so first time it fires queries to retrieve object but rest of the iterations it uses directly from the cache.

                2) My problem is, when I test this configuration through a web application. I am passing same parameters to findEntityQuery(Map, Map) every time but each time it fires query instead of using from cache. Application architecture is like ejb layer -> service layer-> dao layer

                In above both test case I am querying database for the same set of parameters every time but with JUnit it works but webapp it does not.

                In fact, I tried other approaches also described on above article, but it just does not work. Please note I have not done any other changes in config xml or override xml files, I have just followed steps in the article.

                Please not the method I am trying to cache is having two Map parameters not just primitives.
                I would appreciate your time.


                • #23
                  Does spring module declarative caching work only for method with primitives parameters? My problem I think is because the method I am trying to cache has two Map as method signatures. Please advice. Thanks!