Java EE 6 分布式事务 - 使用 Glassfish v3.0.1 获取 JTS5031 异常
我正在尝试在两个 PostgreSQL 数据库之间进行分布式事务。我正在使用 Glassfish v3.0.1。
在我的 GlassFish 域中,我将两个连接池设置为资源类型为 javax.sql.XADataSource,类名称为 org.postgresql.xa.PGXADataSource。
我正在尝试对访问两个数据库的无状态 EJB 方法创建集成测试。为了执行集成测试,我创建了 glassfish 的嵌入式版本,并通过 JNDI 查找 EJB。
当我运行仅涉及一个持久性单元的集成测试时,它们工作正常。
这是我尝试做的第一个分布式事务,所以我不确定一切是否设置正确。
我真的不确定如何找到有关如何解决此问题的信息,因为我不太确定堆栈的含义。我查看了 myDomain/logs 中的日志,但找不到任何内容 - 还有其他日志吗?堆栈跟踪如下:
javax.ejb.EJBException:无法完成容器管理的事务。 在 com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5002) 在 com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4756) 在com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1955) 在com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1906) 在 com.sun.ejb.containers.EJBLocalObjectInvocableHandler.invoke(EJBLocalObjectInitationHandler.java:198) 在com.sun.ejb.containers.EJBLocalObjectInitationHandlerDelegate.invoke(EJBLocalObjectInitationHandlerDelegate.java:84) 在 $Proxy101.createAccount(来源不明) 在 cheetah.services.impl.EJB31_Generate_AccountService_Intf_Bean_.createAccount(来源未知) 在 cheetah.services.tests.integration.AccountServiceTest.createAccount_ValidParameters_AccountCreated(AccountServiceTest.java:60) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在 java.lang.reflect.Method.invoke(Method.java:597) 在 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) 在 org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) 在 org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) 在 org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) 在 org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) 在 org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) 在org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79) 在org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71) 在org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) 在 org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) 在 org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) 在 org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) 在 org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) 在 org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) 在 org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) 在 org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) 在 org.junit.runners.ParentRunner.run(ParentRunner.java:236) 在 org.junit.runners.Suite.runChild(Suite.java:128) 在 org.junit.runners.Suite.runChild(Suite.java:24) 在 org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) 在 org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) 在 org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) 在 org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) 在 org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) 在 org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) 在 org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) 在 org.junit.runners.ParentRunner.run(ParentRunner.java:236) 在junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39) 在org.apache.tools.ant.taskdefs.可选.junit.JUnitTestRunner.run(JUnitTestRunner.java:518) 在org.apache.tools.ant.taskdefs.可选.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1052) 在org.apache.tools.ant.taskdefs.可选.junit.JUnitTestRunner.main(JUnitTestRunner.java:906) 引起原因:javax.transaction.SystemException:org.omg.CORBA.INTERNAL:JTS5031:资源[回滚]操作上的异常[org.omg.CORBA.INTERNAL:vmcid:0x0次要代码:0完成:也许]。 vmcid: 0x0 次要代码: 0 已完成: 否 在 com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:330) 在com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.commitDistributedTransaction(JavaEETransactionManagerJTSDelegate.java:158) 在com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(JavaEETransactionManagerSimplified.java:843) 在 com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:4991) ... 43 更多
I'm trying to do a distributed transaction between two PostgreSQL databases. I'm using Glassfish v3.0.1.
In my GlassFish domain I have my two connection pools setup to have a resource type of javax.sql.XADataSource with a class name of org.postgresql.xa.PGXADataSource.
I'm trying to create an integration test on a stateless EJB method that is hitting both databases. To perform the integration test I am creating an embedded version of glassfish, and looking up the EJB through JNDI.
When I run integration tests that only involve one persistence unit, they are working fine.
This is the first distributed transaction that I'm trying to do, so I'm not sure if everything is set up right.
I'm really not sure about how to find information on how to solve this, as I'm not really sure what the stack is getting at. I've looked at the logs in myDomain/logs and couldn't find anything - are there any other logs? The stack trace is below:
javax.ejb.EJBException: Unable to complete container-managed transaction.
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5002)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4756)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1955)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1906)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:198)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:84)
at $Proxy101.createAccount(Unknown Source)
at cheetah.services.impl.EJB31_Generated_AccountService_Intf_Bean_.createAccount(Unknown Source)
at cheetah.services.tests.integration.AccountServiceTest.createAccount_ValidParameters_AccountCreated(AccountServiceTest.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:518)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1052)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:906)
Caused by: javax.transaction.SystemException: org.omg.CORBA.INTERNAL: JTS5031: Exception [org.omg.CORBA.INTERNAL: vmcid: 0x0 minor code: 0 completed: Maybe] on Resource [rollback] operation. vmcid: 0x0 minor code: 0 completed: No
at com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:330)
at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.commitDistributedTransaction(JavaEETransactionManagerJTSDelegate.java:158)
at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(JavaEETransactionManagerSimplified.java:843)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:4991)
... 43 more
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了类似的问题(CORBA 错误 JTS5031),结果是因为 glassfish 想要一个准备好的事务(我使用它的 2 年里从来没有想要过),而我的 dbms (postgres) 没有配置为使用它们。
尝试查看你的 postgres 日志
I had a similar problem (CORBA error JTS5031) that turned out to be because glassfish wanted a prepared transaction (which it's never wanted in the 2 years I've been using it) and my dbms (postgres) wasn't configured to use them.
try looking in your postgres logs