aspose file tools*
The moose likes Spring and the fly likes Spring AOP Exception handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring AOP Exception handling" Watch "Spring AOP Exception handling" New topic
Author

Spring AOP Exception handling

Rakesh Jhamb
Ranch Hand

Joined: Jun 18, 2003
Posts: 154
Hello All,

I read about spring AOP exception handling... I was able to successfully create a advice and that advice is being invoked whenever the exception occurs in my application.

My question is that thought the advice is being invoked for exceptions, but my exception is still not caught inside the advice...the advice class's method gets executed and the exception is still thrown and the stack trace is printed.

Can I not configure an advice in the application that catches the exception whenever an exception is thrown inside the application.

Or maybe I am understanding the design of AOP exception handling in a wrong manner, please throw some light on this problem.


Thanks.


SCJP2, SCWCD
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Can you post some example code on what you are doing in your advice method?

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Rakesh Jhamb
Ranch Hand

Joined: Jun 18, 2003
Posts: 154
Inside the advice method, I am just logging it to a log file.
Rakesh Jhamb
Ranch Hand

Joined: Jun 18, 2003
Posts: 154
Please respond back.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Rakesh Jhamb wrote:Inside the advice method, I am just logging it to a log file.


Exactly, so you are then going to see


but my exception is still not caught inside the advice...the advice class's method gets executed and the exception is still thrown and the stack trace is printed.



You have to do something with your exception or not allow the exception to be thrown through the method. Remember one of the parameters is the Exception. Usually what people do is check the type of the Exception (for a generic exception handler) or if it is specific then they already know the type of the Exception. But you can then rewrap the exception to throw a more "client" approved exception, so that the clients see a prettier display.

Mark
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Rakesh Jhamb wrote:Please respond back.

PatienceIsAVirtue!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring AOP Exception handling