Announcement Announcement Module
No announcement yet.
@Around with @annotation not being called Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Around with @annotation not being called

    Hi guys,

    I'm having an issue with the 'at'Around and 'at'annotation annotations with spring.

    In my project, we created an aspect to log the request and response parameters of our webservices. We then created an annotation to mark which webservices we would like this to happen. However, this is not working in any fashion. The 'at' signs are explicitly written because of forum limitations...

    Here are some code:

    the marking annotation:

    public 'at'interface ServiceLogging {
    	String service();
    the aspect class with the pointcut:

    public class Logger {
    	public Object logService(ProceedingJoinPoint joinPoint, ServiceLogging serviceLogging) throws Throwable {
    //logging code here
    a snippet from the webservice:

    	'at'ServiceLogging(service="Audit Service")
    	public AuditReportResponseDocument auditReport(AuditReportRequestDocument doc) throws XmlException {
    // web service code
    and in my context.xml configuration, I have the following to enable aspects:
    <bean class="org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator" />
    My environment is BEA Weblogic 10.2, using BEA Workshop and Spring 2.0.7. What is really disturbing is that this was working exceptionally fine, and then one day, boom! it stopped without any aparent reason. Now I cannot make this work again.

    Does anyone have any ideas on this?


  • #2
    We seem to have found the issue.

    Our class uses both the springframwework.Transactional and our ServiceLogging annotations. When we take out the Transactional, everything goes fine.

    In our context, we used to use DefaultAdvisorAutoProxyCreator to proxy the Transactional classes, and now with aspects, we are using AnnotationAwareAspectJAutoProxyCreator, but apparently, they are not compatible with each other.

    Is there an auto-proxy that creates both aspect and transactional proxies? Or do I have to create my own auto-proxy creator, extending the existing ones?


    • #3

      What is wrong with <tx:annotation-driven /> and <aop:aspectj-autoproxy /> they should work perfectly together....


      • #4

        I don't understand what's going on. I did some testing, and everytime I annotated my class with @Transactional, the other annotation stopped working.

        I was looking into the execution logs, and whenever I had @Transactional in my class, Spring was not creating the bean that implements my custom annotation. When I took the Transactional off, I could clearly see the bean being created in the log.

        I didn't try yet using <aop:auto-proxy/>, but I assume it does the same as the AnnotationAwareAspectJAutoProxyCreator, isn't it?

        I'll try testing now using the Order parameter of the Ordered interface to see if it works...


        • #5

          Well, turns out this is working now!!

          Instead of explicitly use the AnnotationAwareAspectJProxyCreator, I tried using just <aop:aspectj-autoproxy proxy-target-class="true"/>, and both annotations are working now!

          It doesn't work if I don't set the proxy-target-class to true, but I guess it's because my services do not have associated interfaces.

          Ah, and I'm also using <tx:annotation-driven/>, instead of the AutoProxyCreator.

          Thanks for showing me the way to <aop:aspectj-autoproxy />!