title: Spring AOP: Aspect not working on called method
body: <p>This is my first time with AOP so this might be very noob question.</p>
  
  <pre><code>public class MyAspect implements AspectI {
  
  public void method1() throws AsyncApiException {
      System.out.println("In Method1. calling method 2");
      method2();
  }
  
  @RetryOnInvalidSessionId
  public void method2() throws AsyncApiException {
      System.out.println("In Method2, throwing exception");
      throw new AsyncApiException("method2", AsyncExceptionCode.InvalidSessionId);
  }
  
  public void login() {
      System.out.println("Logging");
  }
  </code></pre>
  
  <p>InvalidSessionHandler looks like this.</p>
  
  <pre><code>@Aspect
  public class InvalidSessionIdHandler implements Ordered {
  
      @Around("@annotation(com.pkg.RetryOnInvalidSessionId)")
      public void reLoginAll(ProceedingJoinPoint joinPoint) throws Throwable {
          System.out.println("Hijacked call: " + joinPoint.getSignature().getName() + " Proceeding");
          try {
              joinPoint.proceed();
          } catch (Throwable e) {
              if (e instanceof AsyncApiException) {
                  AsyncApiException ae = (AsyncApiException) e;
                  if (ae.getExceptionCode() == AsyncExceptionCode.InvalidSessionId) {
                      System.out.println("invalid session id. relogin");
                      AspectI myAspect = (AspectI) joinPoint.getTarget();
                      myAspect.login();
                      System.out.println("Login done. Proceeding again now");
                      joinPoint.proceed();
                  }
              }
          }
      }
  
      @Override
      public int getOrder() {
          return 1;
      }
  }
  </code></pre>
  
  <p>Spring configuration</p>
  
  <pre><code>&lt;aop:aspectj-autoproxy /&gt;
  &lt;bean id="myAspect" class="com.pkg.MyAspect" /&gt;
  &lt;bean id="invalidSessionIdHandler" class="com.pkg.InvalidSessionIdHandler" /&gt;  
  </code></pre>
  
  <ol>
  <li><p>My intent is when I call <code>myAspect.method1()</code> which in turns calls <code>method2</code>, if <code>method2</code> throws <code>InvalidSessionId</code> Exception, then only <code>method2</code> should be retried. But above code does not seem to do anything. It just immediately returns after exception is thrown from method2. However if I put <code>@RetryOnInvalidSessionId</code> on <code>method1</code> then whole <code>method1</code> is retried.</p></li>
  <li><p>For learning I kept <code>method2</code> is public but in actual I want it to be <code>private</code>. I am out of clue here, how to retry private method.</p></li>
  </ol>
  
  <p>Any suggestions would be helpful.</p>
  
  <p>Thanks</p>