title: Spring AOP transaction annotation not working on method invoked using java reflection
body: <p>I have a method in my <code>@Transaction</code> enabled class which is getting invoked from outside class using java reflection. Unfortunately Spring Transaction is not working inside this method.
  Class looks something like below:</p>
  
  <pre><code>@Transactional
  public class CartServiceImpl implements CartService {
  
  @Autowired
  AnnotatedMethodInvoker annotatedMethodInvoker;
  
  @Override
  @VersionedParent
  public BasicResponse addCartItem(AddCartItemRequest addCartItemRequest) throws Exception{
      String currentMethodName = Thread.currentThread().getStackTrace()[1].getMethodName();
      return (BasicResponse)annotatedMethodInvoker.invoke(this, currentMethodName, addCartItemRequest, AddCartItemRequest.class);
  }
  
  @VersionedMethod(parentMethod="addCartItem", minimumVersion=Constants.BUILD_VERSION_1_0_1, description="Added Epoch")
  private BasicResponse addCartItemWithEpoch(AddCartItemRequest addCartItemRequest){
        /***** Implementation detail goes here *****/
  }
  
  @VersionedMethod(parentMethod="addCartItem", minimumVersion=Constants.BUILD_VERSION_1_0_2, description="Added Cart filter here")
  private BasicResponse addCartItemWithCartFilter(AddCartItemRequest addCartItemRequest){
        /***** Implementation detail goes here *****/
  }
  </code></pre>
  
  <p>}</p>
  
  <p>In the <code>AnnotatedMethodInvoker</code> class's <code>invoke()</code> method I am invoking 1 of the two <code>private</code> methods  <code>addCartItemWithEpoch()</code> &amp;  <code>addCartItemWithCartFilter()</code>.</p>
  
  <p>The problem is that when a RuntimeException is occurring, the Transaction is still getting committed, which essentially means that Spring Transaction is not working in my private method.
  Surprizingly the below statement returns true if I put it inside my private method:</p>
  
  <pre><code>TransactionSynchronizationManager.isActualTransactionActive()
  </code></pre>
  
  <p>My application is currently using Spring AOP transaction throughout and it works seamlessly. application-config.xml snippet below:</p>
  
  <pre><code>&lt;context:annotation-config /&gt;
  &lt;context:component-scan base-package="com.apraxalpha.dealernews" /&gt;
  &lt;tx:annotation-driven /&gt;
  </code></pre>
  
  <p>I have read this <a href="http://blog.timmlinder.com/2011/01/spring-transactional-checking-for-transaction-support-and-local-method-calls/" rel="nofollow">blog</a> which suggests using AspectJ based Transaction over Spring AOP Transaction approach. I am not really confident about this, because my entire application is otherwise using Spring AOP based Transaction. now just for 1 single implementation change, I don't want to change everything to AspectJ transaction. 
  1) Is there any such middle path to have both the approaches in my application ?
  2) Is there any other way to have Transaction in my private method getting invoked using java reflection?</p>