Spring caching issues when using AspectJ LTW

I use the cache abstraction mechanism from Spring 3.0 RC1: I configured the bytecode (based on AspectJ) so that the cache mechanism can be applied to methods called inside the class itself. It is worth saying that at first I used a proxy approach: everything worked fine (for methods it is called from another object.)

As soon as I switch to AspectJ (I activated LTW through, added the correct banks to my place - everything works fine, no exceptions are thrown), caching does not occur

Any suggestion? Thank.

==== later edit =========

I installed the logs in DEBUG for org.springframework.

If you use proxy mode, I can clearly see the message Adding the cache method getLargeAssetContent .... where getLargeAssetContent is my "cache" method ... (see below)

If you use aspectj mode, I don’t see this message .... all requests go to the DAO level ... where, as in the situation when the cache is running, the requests stop at the service level.

What am I doing wrong? Do I need aop.xml? I haven't used AOP .... so I don't have aop.xml yet.

Thank you for your help.

*> * 2011-12-12 16: 38: 55,998 DEBUG [org.springframework.cache.annotation.AnnotationCacheOperationSource]

(http-127.0.0.1-8080-6) 'getLargeAssetContent' : [CacheOperation [public com.mycompany.myprj.model.AssetContent com.mycompany.myprj.dao.jcr.AssetDAOImpl.getLargeAssetContent(java.lang.String) throws com.mycompany.myprj.dao.MyPrjPersistenceException] caches = [] | = '' | key = '# nodeId'] 2011-12-12 16: 38: 56,013 INFO [com.mycompany.myprj.dao.jcr.AssetDAOImpl] (http-127.0.0.1-8080-6) (getLargeAssetContent) node id = 575d8dc0-01be-41e4-85ce-a654fab97fe8 2011-12-12 16: 38: 56,092 INFO [com.mycompany.myprj.dao.jcr.AssetDAOImpl] (http-127.0.0.1-8080-6) node ID = 575d8dc0-01be-41e4-85ce-a654fab97fe8 **

*

// 2011-12-12 16: 38: 57,654 DEBUG [Org.springframework.beans.factory.support.DefaultListableBeanFactory] (http-127.0.0.1-8080-6) singleton bean'assetController' 2011-12-12 16: 38: 57,654 DEBUG [Org.springframework.web.servlet.DispatcherServlet] (http-127.0.0.1-8080-6) [/myprj/asset/get/575d8dc0-01be-41e4-85ce-a654fab97fe8]: -1 2011-12-12 16: 38: 57 654 INFO [com.mycompany.myprj.services.AssetService] (http-127.0.0.1-8080-6) : 57

*

+5
2

, AspectJ (. 28.3.3 ):

<cache:annotation-driven mode="aspectj"/>

proxy, LTW ( aspectj IMHO, ).

- ?

+1

, aspectj LTW

  • <cache:annotation-driven mode="aspectj"/>
  • aspectj-weaver spring - ( ClassNotFoundException)
  • aop.xml -INF/aop.xml( - - - JVM, )
  • <context:load-time-weaver aspectj-weaving="on"/> ( autodetect, , META-INF/aop.xml )
  • javaagent VM spring -instrument, . , javaagent , reference.
0

All Articles