Spring JTA配置 - 如何设置TransactionManager? [英] Spring JTA configuration - how to set TransactionManager?
问题描述
我们将Spring配置中的Spring事务配置为:
We configure our Spring transaction in Spring config as:
<tx:jta-transaction-manager/>
我收集这意味着Spring会自动发现底层的JTA实现。因此,当我们启动JBoss时,我们会在Spring搜索时看到这些消息:
I gather this means that Spring will automatically discover the underlying JTA implementation. So when we start up JBoss we see these messages while Spring searches:
[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日志记录级别)
Question is - how can we edit our <tx:jta-transaction-manager/>
tag to explicitly configure the java:/Transaction Manager
JTA implementation so we avoid all these stack traces in the logs? (I'd prefer not to just change the Log4J logging levels)
更新:我用下面的配置替换< tx:jta-transaction-manager />
它似乎有效..我猜这是好的吗?
Update: I replaced <tx:jta-transaction-manager/>
with the below config and it seems to work.. i'm guessing this is alright?
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManagerName" value="java:/TransactionManager"/>
</bean>
推荐答案
是的,没关系。您看到的堆栈跟踪也没问题:< tx:jta-transaction-manager />
尝试从多个不同的标准位置获取事务管理器;对于每个失败的JNDI查找,您将看到 javax.naming.NameNotFoundException
。
Yes, that's alright. The stack trace you were seeing was also alright: <tx:jta-transaction-manager/>
tries to acquire the transaction manager from a number of different standard locations; for every failed JNDI lookup, you'll see the javax.naming.NameNotFoundException
.
java:/ TransactionManager
是JBoss默认绑定的地方;其他servlet容器将默认为 java:/ comp / TransactionManager
,我认为它应该是TM的标准位置。
java:/TransactionManager
is where JBoss binds to by default; other servlet containers will default to java:/comp/TransactionManager
, which I think is supposed to be the "standard" location for the TM.
来自 Spring参考文档:
对于标准方案,包括
WebLogic,WebSphere和OC4J,请考虑
使用方便的
< tx:jta-transaction-manager />
配置元素。这将
自动检测基础
服务器并选择可用于该平台的最佳交易
经理。
这意味着您将不必为
配置特定于服务器的适配器
类(如以下
部分中所述);他们宁愿自动选择
,
标准JtaTransactionManager
为
默认回退。
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 standardJtaTransactionManager
as default fallback.
这篇关于Spring JTA配置 - 如何设置TransactionManager?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!