为什么我得到“不是 NamedXAResource"?在 Apache Karaf 4.0.4 中? [英] Why am I getting "is not a NamedXAResource" in Apache Karaf 4.0.4?

查看:25
本文介绍了为什么我得到“不是 NamedXAResource"?在 Apache Karaf 4.0.4 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些交易代码在旧版本的 Apache Karaf 中运行良好.现在在 Apache Karaf 4.0.4 中,我看到了很多异常.

I have some transactional code that worked very well in old versions of Apache Karaf. Now in Apache Karaf 4.0.4 I see a lot of exceptions.

java.lang.IllegalStateException:无法记录事务,因为 org.apache.derby.jdbc.EmbedXAResource@77cbf3e5 不是 NamedXAResource.

org.apache.aries.transaction.manager - 1.3.0 |请更正集成并提供 NamedXAjava.lang.IllegalStateException:无法将事务记录为 TransactionContext{transactionId=null,connection=ActiveMQConnection

推荐答案

我找到了答案并将其张贴在这里,以便让其他人更快地解决相同的问题.我花了很长时间才弄明白这个问题,并得到了纪尧姆的帮助.

I found the answer and post it here to give others a quicker way to solve the same problem. It took me quite a while and some help from Guillaume to figure this out.

在 Aries 事务管理器包内的 Apache Karaf 中使用的 geronimo 事务管理器可以恢复事务.默认情况下,此功能在较旧的 karaf 版本中处于关闭状态.在 Apache Karaf 4.0.4 中,这已经改变了.

The geronimo transaction manager that is used in Apache Karaf inside the Aries transaction manager bundle can recover transactions. By default this feature is switched off in older karaf versions. In Apache Karaf 4.0.4 this has changed.

配置 etc/org.apache.aries.transaction.cfg 包含此设置

The config etc/org.apache.aries.transaction.cfg contains this setting

aries.transaction.recoverable = true

它激活了恢复支持.这样做的缺点是所有 jdbc 和 jms 连接都必须实现 NamedXAResource.这超出了标准,因此大多数 jdbc 和 jms 提供商不支持这一点.

It activates the recovery support. The downside of this is that all jdbc and jms Connections must then implement NamedXAResource. This is outside the standard so most jdbc and jms providers do not support this.

ActiveMQ 的解决方案是使用 JCAPoolingConnectionFactory.对于 jdbc,您可以使用 aries 事务 jdbc 包装您的 XADataSource.它提供了一个池支持,也支持恢复.

The solution for ActiveMQ is to use the JCAPoolingConnectionFactory. For jdbc you can wrap your XADataSource using aries transaction jdbc. It provides a pooling support that also supports recovery.

如果您对应用程序的工作方式感到满意,则可以简单地将上述开关设置回 false.然后事务将像在较旧的 Apache Karaf 版本中一样工作.

If you are happy with how your application worked before you can simply set the above switch back to false. The transactions will then work like in older Apache Karaf versions.

这篇关于为什么我得到“不是 NamedXAResource"?在 Apache Karaf 4.0.4 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆