File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes Exception Interceptor Throws Advice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Exception Interceptor Throws Advice " Watch "Exception Interceptor Throws Advice " New topic

Exception Interceptor Throws Advice

nazzy khan
Ranch Hand

Joined: May 06, 2010
Posts: 39


I have created a throws advice for my command bean ( for handling exception and logging when exception is thrown from my command.

LoginAction -> Login command

Both action and command is defined in ApplicationContext.xml file as below

When an exception is thrown from my command, my interceptor class ( will be called. I'm throwing NullPointerException from command. I want the exact line of the command class from where exception is thrown.

ex.getClass().getName() prints only "java.lang.NullPointerException"but not the line no.

code below:

Caught: java.lang.NullPointerException
Class: Login
Method: doExecute

How do I get the line no in ExceptionInterceptor class?

nazzy khan
Ranch Hand

Joined: May 06, 2010
Posts: 39

Sorry my bad.. It was very easy.

I have not tried printStackTrace()

getMessage returned null.. then I thought printStackTrace() will also not work.

printStackTrace() returns the complete stack trace along with the line where exception is thrown.


I agree. Here's the link:
subject: Exception Interceptor Throws Advice
It's not a secret anymore!