java – Spring JTA配置 – 如何设置TransactionManager?

前端之家收集整理的这篇文章主要介绍了java – Spring JTA配置 – 如何设置TransactionManager?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我们将 Spring配置中的 Spring事务配置为:
<tx:jta-transaction-manager/>

我收集这意味着Spring会自动发现基础的JTA实现.所以当我们启动JBoss时,我们看到这些消息,而Spring搜索

[JtaTransactionManager] [ ] No JTA TransactionManager found at fallback JNDI location [java:comp/Tran
sactionManager]
javax.naming.NameNotFoundException: TransactionManager not bound
<<Big stack trace>>    
<<More of the same>>

然后最终看到:

[JtaTransactionManager] [ ] JTA TransactionManager found at fallback JNDI location [java:/Transaction
Manager]
[JtaTransactionManager] [ ] Using JTA UserTransaction: org.jboss.tm.usertx.client.ServerVMClientUserT
ransaction@1f78dde

问题是 – 我们如何编辑我们的< tx:jta-transaction-manager />标签显式配置java:/ Transaction Manager JTA实现,所以我们避免了日志中的所有堆栈跟踪? (我不想只是更改Log4J日志记录级别)

更新:我替换了< tx:jta-transaction-manager />与下面的配置,它似乎工作..我猜这是没事的?

<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
    <property name="transactionManagerName" value="java:/TransactionManager"/>
</bean>

解决方法

是的,没关系您所看到的堆栈跟踪也是如此:< tx:jta-transaction-manager />尝试从多个不同的标准位置获取交易管理器;对于每个失败的JNDI查找,您将看到javax.naming.NameNotFoundException.

java:/ TransactionManager是JBoss在默认情况下绑定的地方;其他servlet容器将默认为java:/ comp / TransactionManager,我认为这应该是TM的“标准”位置.

Spring reference documentation

For standard scenarios,including
WebLogic,WebSphere and OC4J,consider
using the convenient
<tx:jta-transaction-manager/>
configuration element. This will
automatically detect the underlying
server and choose the best transaction
manager available for the platform.
This means that you won’t have to
configure server-specific adapter
classes (as discussed in the following
sections) explicitly; they will rather
be chosen automatically,with the
standard JtaTransactionManager as default fallback.

原文链接:https://www.f2er.com/java/123644.html

猜你在找的Java相关文章