Announcement Announcement Module
Collapse
No announcement yet.
configure AOP rollback Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • configure AOP rollback

    Hi, I'm becoming mad, I'm new to spring-aop, but I would like know where I make a mistake:
    I attached my entire application context.xml but the following section is that concerned

    <!-- LOGGING AOP ASPECT -->
    <aop:config>
    <aop:aspect ref="LoggingAspect">
    <aop: pointcut id="myCutLogging" expression="execution(* gestalle.hibernate.EmployeeDao2_HibernateTemplate. *(..))"/>
    <aop:around pointcut-ref="myCutLogging" method="log"/>
    <aop:after-throwing pointcut-ref="myCutLogging" method="after_throwing"/>
    </aop:aspect>
    </aop:config>

    <tx:advice id="txAdvice" transaction-manager="txManager">
    <!-- the transactional semantics... -->
    <tx:attributes>
    <tx:method name="main" propagation="REQUIRED" rollback-for="java.lang.Exception" />

    </tx:attributes>
    </tx:advice>

    <aop:config>
    <aop: pointcut id="SpringHibernateTestOperation"
    expression="execution(* gestalle.test.SpringHibernateTest.*(..))" />

    <aop:advisor advice-ref="txAdvice" pointcut-ref="SpringHibernateTestOperation" />
    </aop:config>


    1) In web.xml there's <welcome-file>index.jsp</welcome-file>
    2) in index.jsp page click on link <s:a href="test.action">test href</s:a>
    3) this is test.action
    <action name="test" method="main" class="gestalle.test.SpringHibernateTest">
    <result>index.jsp</result>
    </action>


    as you could seen from applicationContext.xml file, I would when I click on 'test href' link, running method main that doing

    public void main(){
    ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(
    new String[] { "/gestalle/applicationContext.xml" });
    WebLogicJtaTransactionManager txManager = (WebLogicJtaTransactionManager) appContext.getBean("txManager");
    IAOP_Library iaop_library = (IAOP_Library) appContext.getBean("employeedao2_hibernatetemplate ");
    Employee empInsert = new Employee();
    Employee empDelete=new Employee();

    empInsert.setName("main di SpringHibernateTest");
    iaop_library.insertEmployee(empInsert);
    System.out.println("POST insertEmployee");
    empDelete.setId("93");
    iaop_library.deleteEmployee(empDelete);
    System.out.println("POST deleteEmployee");
    System.out
    .println("ECCOMIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII - main di SpringHibernateTest");
    }


    In DB there isn't the record Id 93
    I would like that record insert fails because I configured the <tx:method name="main" propagation="REQUIRED" rollback-for="java.lang.Exception" />

    instead record insert succesfully and by BEA-domain-log read
    org.springframework.orm.hibernate3.HibernateOptimi sticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

    Why do fails the transaction?

    Thanks for your help

  • #2
    1) Use [ code][/code ] tags when posting code
    2) Read chapter 6 of the reference guide (especially 6.6.1)
    3) Try to use 1 aop:config block to avoid double proxying
    4) You are using JTA make sure everything you use works with JTA (i.e. is XA capable).

    You cannot advice a bean that spring doesn't know about... The bean you are trying to advice is
    1) Instantiating the application context itself
    2) The bean is instantiated by struts not spring (as I stated spring only advices beans it knows about)
    3) You are trying to advice the bean that is instantiating the application context... Ehrm....

    Comment


    • #3
      Originally posted by Marten Deinum View Post
      1) Use [ code][/code ] tags when posting code
      2) Read chapter 6 of the reference guide (especially 6.6.1)
      3) Try to use 1 aop:config block to avoid double proxying
      4) You are using JTA make sure everything you use works with JTA (i.e. is XA capable).

      You cannot advice a bean that spring doesn't know about... The bean you are trying to advice is
      1) Instantiating the application context itself
      2) The bean is instantiated by struts not spring (as I stated spring only advices beans it knows about)
      3) You are trying to advice the bean that is instantiating the application context... Ehrm....
      Excuse me for these questions:
      1) ok, I don't knew it
      2) where can I discover it?Please, give me a link
      3) ok, I joined two aop:config blocks such
      Code:
      <aop:config>
      	<aop:pointcut id="SpringHibernateTestOperation"
      		expression="execution(* gestalle.test.SpringHibernateTest.*(..))" /> 
      	<aop:advisor advice-ref="txAdvice" pointcut-ref="SpringHibernateTestOperation" />
      	<aop:aspect ref="LoggingAspect">	   
      	     <aop:pointcut id="myCutLogging" expression="execution(* gestalle.hibernate.EmployeeDao2_HibernateTemplate.*(..))"/>	   
      	     <aop:around pointcut-ref="myCutLogging" method="log"/>
      	     <aop:after-throwing pointcut-ref="myCutLogging" method="after_throwing"/>
      	</aop:aspect>
      </aop:config>
      4)I implementing Global transaction management strategy through application server BEA weblogic 8.1.6

      About 1) 2) 3) of second section response, I don't understand what's wrong, I am inexperienced...
      Please, help me.

      Many thanks

      Comment

      Working...
      X