13

我们在 Spring config 中将 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 ManagerJTA 实现,从而避免日志中的所有这些堆栈跟踪?(我不希望只更改 Log4J 日志记录级别)


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

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

2 回答 2

13

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 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.

From the Spring reference documentation:

对于标准场景,包括 WebLogic、WebSphere 和 OC4J,考虑使用方便的 <tx:jta-transaction-manager/> 配置元素。这将自动检测底层服务器并选择可用于平台的最佳事务管理器。这意味着您不必显式配置特定于服务器的适配器类(如以下部分所述);他们宁愿自动选择,标准JtaTransactionManager作为默认后备。

于 2009-11-23T15:55:17.793 回答
4

jta.jar一个常见的“错误”是将诸如和/或之类的东西捆绑jbossall-client.jar在您部署的 J2EE 组件中。如果是这种情况,请仔细检查并删除它们。

于 2009-11-23T14:57:51.840 回答