Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Unexpected/inappropriate application of rule based transaction attributes

  1. #1
    Join Date
    Dec 2006
    Posts
    13

    Question Unexpected/inappropriate application of rule based transaction attributes

    I have two similar beans defined, one bean when invoked will call for :

    [org.springframework.transaction.interceptor.RuleBa sedTransactionAttribute] - <Applying rules to determine whether transaction should rollback on null>
    2006-12-01 12:28:48,857 DEBUG [org.springframework.transaction.interceptor.RuleBa sedTransactionAttribute] - <Winning rollback rule is: RollbackRule with pattern [Exception]>
    2006-12-01 12:28:48,857 DEBUG [org.springframework.transaction.interceptor.Transa ctionInterceptor] - <Invoking rollback for transaction on se.lantmateriet.alp.bus.UnderrattelseService.under ratta due to throwable [null]>
    2006-12-01 12:28:48,867 DEBUG [org.springframework.orm.hibernate3.HibernateTransa ctionManager] - <Triggering beforeCompletion synchronization>
    2006-12-01 12:28:48,867 DEBUG [org.springframework.orm.hibernate3.HibernateTransa ctionManager] - <Initiating transaction rollback>

    and thereby rollback (not being able to start the transaction).
    The other bean works fine.

    Here is the beandef for:
    shared parent defination:
    <bean id="abstractService" abstract="true" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager">
    <ref bean="transactionManager"/>
    </property>
    <property name="transactionAttributes">
    <props>
    <prop key="doCommitThru*">PROPAGATION_REQUIRES_NEW,-Exception</prop>
    <prop key="*">PROPAGATION_REQUIRED,-Exception</prop>
    </props>
    </property>
    </bean>
    the bean that does not work:
    <bean id="underrattelseService" parent="abstractService">
    <property name="proxyInterfaces">
    <value>se.lantmateriet.alp.bus.UnderrattelseServic e</value>
    </property>
    <property name="target">
    <bean id="underrattelseTarget" class="se.lantmateriet.alp.bus.UnderrattelseServic eImpl" parent="abstractServiceTarget">
    <property name="usDao">
    <ref bean="usDaoDelegate"/>
    </property>
    <property name="utskick">
    <ref bean="utskickService"/>
    </property>
    </bean>
    </property>
    </bean>
    the bean that works:
    <bean id="godkannPaminnService" parent="abstractService">
    <property name="proxyInterfaces">
    <value>se.lantmateriet.alp.bus.GodkannPaminnServic e</value>
    </property>
    <property name="target">
    <bean id="godkannTarget" class="se.lantmateriet.alp.bus.GodkannPaminnServic eImpl" parent="abstractServiceTarget">
    <property name="usDao">
    <ref bean="usDaoDelegate"/>
    </property>
    <property name="utskick">
    <ref bean="utskickService"/>
    </property>
    </bean>
    </property>
    </bean>

    codes to run
    ClassPathResource res = new ClassPathResource(
    "alp-context-local.xml");
    XmlBeanFactory factory = new XmlBeanFactory(res);
    UnderrattelseService urs = (UnderrattelseService) factory.
    getBean("underrattelseService");
    System.exit(urs.underratta());

    similar codes to run the other bean. Note that execution will not even enter method underratta().

    The two beans used to work well for a long time, then "suddenly" application of rulebased for transaction invokes and causing rollback!

    I have been starring at the beandef.xml for many many minutes ... I didn't check the code changes because the problem arises at entry underratta().
    I appreciate any clues or response ! Thanks.

    /Kwan

  2. #2
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    So your saying when you call the method on one service it works and on the other it causes a rollback? Have you debugged UnderrattelseService to see why it causes the rollback? Something might actually be going wrong in this service.

  3. #3
    Join Date
    Dec 2006
    Posts
    13

    Default

    you see the execution will not go into UnderrattelseService, it does a rollback because a rule check was performed. This rule check was not performed for godkannPaminnService (and therefore godkannPaminnService can run and complete).
    The two services have almost identical definition in beandef, this puzzles me.
    /Kwan

  4. #4
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Can you post a more complete log. Also try actually debugging it and see where it goes wrong.

  5. #5
    Join Date
    Dec 2006
    Posts
    13

    Default

    The two attached files are debug logs for the two services.
    As you can see that they are almodt identical, except for underrattaelseService a rule check applies just before entry into the class. (do a search on "rule" in these logs).

    /Kwan
    Attached Files Attached Files

  6. #6
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Can we see the code and the applicationContext?

  7. #7
    Join Date
    Dec 2006
    Posts
    13

    Default

    codes attached. What is application context ?
    /Kwan
    Attached Files Attached Files

  8. #8
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    The XML configuration file that contains all the bean definitions.

  9. #9
    Join Date
    Dec 2006
    Posts
    13

    Default

    of course !
    Attached Files Attached Files

  10. #10
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    OK, I'll take a look in a hour or two when I get home.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •