Announcement Announcement Module
No announcement yet.
ThrowsAdvice problem Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • ThrowsAdvice problem

    Hi Friends,

    I am trying to impliment ThrowsAdvice in my project. I am facing a strange problem.

    Here is my throws advice implimentation class

    public class DaoExceptionAdvice implements ThrowsAdvice{

    private Log log = LogFactory.getLog(this.getClass());

    public void afterThrowing(Exception ex) throws CustomException{

    log.error("\n\t ***** Generic Exception Capture. Caught: "
    + ex.getClass().getName() + "\n\t ***** \n");
    throw new CustomException("Exception Capture in DAO" + "method name" , ex);

    public void afterThrowing (Method m, Object[] args, Object target, Exception ex) throws CustomException{
    // System.out.println("Exception Capture in DAO" + target);
    //System.out.println("method name" + method.getName());
    System.out.println("Exception caught: " + ex.getClass().getName());

    throw new CustomException("Exception Capture in DAO" + "method name" , ex);

    The problem is whenver I add the second afterThrowing method that takes 4 aruements, none of the methods get called when an exception is thown by my bean class.
    If I remove the second method (with 4 arguments), the first method gets called with out any problem.
    I am not sure why this is happening.

    Here is my content from configuration file:
    <bean id="daoThrowsAdvice" class=" Advice"/>

    <bean id="daoExceptionAdvice" class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator">
    <property name="beanNames">
    <property name="interceptorNames">

    Thanks in advance for your help.