我正在使用 spring、oracle 和 jotm(在 tomcat 中)来使用 2PC 提交。下面是弹簧配置。
<aop:config>
<aop:pointcut id="defaultOperation"
expression="execution(* jatis.avantrade.foundation.model.engine.*.*(..))" />
<aop:advisor advice-ref="defaultTrxAdvice" pointcut-ref="defaultOperation" />
</aop:config>
<tx:advice id="defaultTrxAdvice" transaction-manager="trxManager">
<tx:attributes>
<tx:method name="check*" read-only="true" />
<tx:method name="get*" read-only="true" />
<tx:method name="is*" read-only="true" />
<tx:method name="load*" read-only="true" />
<tx:method name="select*" read-only="true" />
<tx:method name="count*" read-only="true" />
<tx:method name="search*" read-only="true" />
<tx:method name="list*" read-only="true" />
<tx:method name="*" rollback-for="Throwable" />
</tx:attributes>
</tx:advice>
<bean id="txImpl" class="org.springframework.transaction.jta.JotmFactoryBean" />
<bean id="trxManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager" ref="txImpl" />
<property name="userTransaction" ref="txImpl" />
</bean>
问题是当我getTransactionManager().getTransaction()
使用 JOTM 对象调用时,它返回 null。
Current cur = (Current) ContextHelper.getApplicationContext()
.getBean("txImpl");
try {
log.error("cur : " cur.getTransactionManager().getTransaction());
} catch (SystemException e) {
log.error(e.getMessage(), e);
}
我该如何解决这个问题?