title: Spring AOP @AfterThrowing Advice not being executed
body: <p>The @AfterThrowing advice I have defined is not getting executed. Could some one take a look and please help me out? Below is the code I am using.</p>
  
  <p><strong>Pom.xml</strong></p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0"     
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0  
  http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;Test&lt;/groupId&gt;
  &lt;artifactId&gt;Test&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;SpringAOPAfterThrowsTest&lt;/name&gt;
  &lt;dependencies&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;org.springframework&lt;/groupId&gt;
    &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
    &lt;version&gt;3.2.4.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;org.springframework&lt;/groupId&gt;
    &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
    &lt;version&gt;3.2.4.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;org.springframework&lt;/groupId&gt;
    &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
    &lt;version&gt;3.2.4.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;org.aspectj&lt;/groupId&gt;
    &lt;artifactId&gt;aspectjrt&lt;/artifactId&gt;
    &lt;version&gt;1.7.3&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;org.aspectj&lt;/groupId&gt;
    &lt;artifactId&gt;aspectjweaver&lt;/artifactId&gt;
    &lt;version&gt;1.7.3&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;junit&lt;/groupId&gt;
    &lt;artifactId&gt;junit&lt;/artifactId&gt;
    &lt;version&gt;4.11&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;org.springframework&lt;/groupId&gt;
    &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
    &lt;version&gt;3.2.4.RELEASE&lt;/version&gt;
   &lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>spring-context.xml</strong></p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    
  xmlns:aop="http://www.springframework.org/schema/aop"
  xmlns:context="http://www.springframework.org/schema/context"  
  xmlns:p="http://www.springframework.org/schema/p"
  xmlns:util="http://www.springframework.org/schema/util"
  xsi:schemaLocation="http://www.springframework.org/schema/aop  
  
  http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
      http://www.springframework.org/schema/beans 
  http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
      http://www.springframework.org/schema/context 
  http://www.springframework.org/schema/context/spring-context-3.2.xsd
      http://www.springframework.org/schema/util 
  http://www.springframework.org/schema/util/spring-util-3.2.xsd"&gt;
  
  
  &lt;aop:aspectj-autoproxy /&gt;
  &lt;bean id="loggingBean" class="com.aop.test.LoggingAspect" /&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>LoggingAspect.java</strong></p>
  
  <pre><code>package com.aop.test;
  
  import org.aspectj.lang.JoinPoint;
  import org.aspectj.lang.annotation.AfterThrowing;
  import org.aspectj.lang.annotation.Aspect;
  
  
  @Aspect
  public class LoggingAspect {
  
  @AfterThrowing(pointcut = "execution(* com.aop..*.*(..))", throwing = "e")
  public void afterThrowingAdvice(final JoinPoint jp, final Exception e) {
      System.out.println("Exception is " + e.getLocalizedMessage());
      System.out.println("Annotation driven:After throwing " +    
  jp.getSignature().getName()
              + "()");
  
  }
  }
  </code></pre>
  
  <p><strong>SampleClassUnderAOP</strong></p>
  
  <pre><code>package com.aop.test;
  
  public class SampleClassUnderAOP {
  
  public void sampleMethod() {
      String str = null;
      System.out.println(str.length());
  }
  
  }
  </code></pre>
  
  <p><strong>TestAOP unit test class</strong></p>
  
  <pre><code>package com.aop.test;
  
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.springframework.test.context.ContextConfiguration;
  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  
  
  @RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration({ "classpath:/spring-context.xml" })
  public class TestAOP {
  
      @Test
      public void test() {
          SampleClassUnderAOP sc = new SampleClassUnderAOP();
          sc.sampleMethod();
      }
  
  }
  </code></pre>