This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Spring and the fly likes Problem with Spring AOP+AspectJ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Problem with Spring AOP+AspectJ" Watch "Problem with Spring AOP+AspectJ" New topic
Author

Problem with Spring AOP+AspectJ

Vladimir Koba
Greenhorn

Joined: May 29, 2012
Posts: 4
Hi all! I want to log every invoke public method in my class. So, i create LoggingAspect class for logging, and configure Spring on xml.
When i start my application, all methods logging three times, for example:
Entering method selectAllCompanies...
Entering method selectAllCompanies...
Entering method selectAllCompanies...

Really, methods invokes one times. I think, that problem in a pointcut, but i'm not sure.

aop-context.xml


LoggingAspect.java
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1632
    
    7

I think this is fixed in newer versions of Spring.

Your problem I believe is that other proxying is being done on your DAO (Transactional etc) and your advice is being called multiple times before the actual POJO is invoked.

See if this link helps you at all.

http://forum.springframework.net/showthread.php?5528-Advice-called-multiple-times-when-using-AttributeMatchMethodPointCut

Thanks,

[How To Ask Questions][Read before you PM me]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with Spring AOP+AspectJ
 
Similar Threads
Simple AOP not working
AOP logging throws exception
Example problem from Spring in Action AOP
Spring AOP question
Spring 2.5 and AOP - BeanPostProcessor before instantiation of bean failed