Overriding global jta timeout in spring context in weblogic

倾然丶 夕夏残阳落幕 提交于 2020-04-06 06:09:45

问题


Our Weblogic have global JTA timeout 30s, since our server is under high load setting such global timout to a bigger value can be critical for performace of the application.

So I want to override this JTA timeout with specific value in context of particular service.

I have root context for a number of webservices it has it's own global transaction manager:

<bean id="jtaTransactionManager" class="org.springframework.transaction.jta.WebLogicJtaTransactionManager">
    <property name="transactionManagerName" value="javax.transaction.TransactionManager"/>
  </bean>

annotation driven for this transation manager is on

<tx:annotation-driven proxy-target-class="true" transaction-manager="jtaTransactionManager"/>

and i have global hibernate session factory :

<bean id="parent.session.factory"
        abstract="true"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
        destroy-method="destroy"
        p:dataSource-ref="dataSource.schedules">
    <property name="hibernateProperties">
      <props>
        <prop key="hibernate.transaction.manager_lookup_class">
          org.hibernate.transaction.WeblogicTransactionManagerLookup
        </prop>
        <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>
        <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
        <prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
        <prop key="hibernate.cache.use_second_level_cache">false</prop>
        <prop key="hibernate.cache.use_query_cache">false</prop>
        <prop key="hibernate.show_sql">false</prop>
        <prop key="hibernate.connection.autocommit">false</prop>
      </props>
    </property>
  </bean>

Then I have the context of my webservice where I want to override the jta timeout:

Inherited local transaction manager:

  <bean id="localTransactionManager" parent="jtaTransactionManager">
    <property name="defaultTimeout" value="120"/>
  </bean>

Bean with javax TransactionManager interface for hibernate:

  <bean id="localEETransactionManager" factory-bean="localTransactionManager"
        factory-method="getTransactionManager">
    <property name="transactionTimeout" value="120"/>
  </bean>

Session factory for Hibernate with lolcaly overrided TransactionManager with EE interface (javax.transaction.TransactionManager)

  <bean id="sessionFactory" parent="parent.session.factory">
    <property name="jtaTransactionManager" ref="localEETransactionManager"/>
    <property name="annotatedClasses">
      <list>
        <value>com.example.City</value>
        <value>com.example.State</value>
        <value>com.example.Country</value>
      </list>
    </property>
  </bean>

And finally the DAO with localy overrided WebLogicJtaTransactionManager:

<bean id="addressDao"
        class="com.example.AddressDataAccessObjectImpl"
        p:entityClass="com.example.City"
        p:dataSource-ref="dataSource"
        p:sessionFactory-ref="sessionFactory"
        p:transactionManager-ref="localTransactionManager"/>

But when I run my application hibernate throws Caused by: weblogic.transaction.internal.TimedOutException: Transaction timed out after 30 seconds

And rolls back the transaction.

Maybe someone know what I'm doing wrong with those overrides?

PS This override works only for root context, if I do somthing like that:

 <bean id="jtaTransactionManager" class="org.springframework.transaction.jta.WebLogicJtaTransactionManager">
    <property name="transactionManagerName" value="javax.transaction.TransactionManager"/>
    <property name="defaultTimeout" value="120"/>
  </bean> 

But that is not what I whant because it is still global for all application.

来源:https://stackoverflow.com/questions/10416149/overriding-global-jta-timeout-in-spring-context-in-weblogic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!