Announcement Announcement Module
Collapse
No announcement yet.
AOP transaction problem with method overriding! Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AOP transaction problem with method overriding!

    Hi guys:

    I meet a very strange situation with the new aspectj way of aop transaction in Spring 2.0.

    if I have a child class to override a method in the parent class. the overriding method in the child class do not roll back for exceptions. other none overriding methods in the child class work fine. I did not use any annotations in my code. Any one has a clue for me? many many thanks!!!

    here is my configuration:

    <tx:annotation-driven />

    <aop:aspectj-autoproxy />

    <aop:config proxy-target-class="false">
    <aop:advisor pointcut="execution(* com.test..*ServiceImpl.*(..))" advice-ref="txAdvice" />
    </aop:config>

    <tx:advice id="txAdvice">
    <tx:attributes>
    <tx:method name="get*" read-only="true" />
    <tx:method name="find*" read-only="true" />
    <tx:method name="*" />
    </tx:attributes>
    </tx:advice>

  • #2
    When posting code please use [ code][ /code] tags, it makes your post more readable.

    If you don't use annotations then why do you use tx:annotation-driven? First I would remove that as well as the aop:aspectj-autoproxy.

    How is the method called? Is it an external call into the bean or is the method called from within the bean?

    Comment


    • #3
      thank you mdeinum, this is my first post here. the annotation-driven was leaving there just in case when i need it. I took out annotation-driven and aspectj-autoproxy, it is still not working for the overriding method. it is an external call from the outside, any clue? many thanks!

      Comment


      • #4
        It would be useful to see some code from this and a TestCase. It's much easier to solve these problems that way.
        Last edited by karldmoore; Aug 29th, 2007, 12:05 PM.

        Comment


        • #5
          below is the stracture of parent and child, hope it helps. I used Generic, is this a metter?

          Code:
          public interface ParentInterface<D> {
          
          	public void save(D o);
          }
          
          public class ParentBaseService<D> implements ParentInterface<D> {
             public void save(D o) {
                ......
             }
          }
          
          public class ChildServiceImpl extends ParentServiceImpl<User>
          implements ChildInterface {
          
             public void save(User o) {
                ...... //some business logic here
                throw new RuntimeException(); //did not roll back
             }
          
             /*
              * some other methods here
              */
          }
          Last edited by zal_wang; Jul 2nd, 2007, 09:34 PM.

          Comment


          • #6
            I wrote a advisor to trace the process, found out something interesting. When the overrided method in the parent class used Generic type parameter, the advisor doesn't execute for the overriding method in the child class. When the overrided method in the parent calss is a regular method, the advisor is executed for the overriding method in the child class. which means the trascation did not work is because Spring AOP did not pointcut for the overriding method while the overrided mehod use Generic type parameter. I thought the Generic information is erased when compilling, it makes me confuse, any explanations???

            Comment


            • #7
              I don't know if it applies here, but might the following bugs be an explanation?

              SPR-3556
              SPR-3628

              Jörg

              Comment


              • #8
                You might give a try with one of the nightly snapshots of 2.0.7 version and see if the bug is still there.
                The bugs mentioned by Jörg Heinicke seem to have something related to your issue.

                Comment


                • #9
                  I tried spring-framework-2.0.7-with-dependencies-20070703-32, Still not working. have to switch to BeanNameAutoProxyCreator, which is working fine. I don't know if this is a bug for Spring or I did not configure it right. Any comments?

                  Comment

                  Working...
                  X