java Weblogic 错误:由:weblogic.transaction.internal.AppSetRollbackOnlyException:setRollbackOnly 调用事务
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31428434/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Weblogic Error: Caused by: weblogic.transaction.internal.AppSetRollbackOnlyException: setRollbackOnly called on transaction
提问by mwangi
I am porting an application from Jboss 7as to Weblogic 12c.
我正在将应用程序从 Jboss 7as 移植到 Weblogic 12c。
So far, I am able to run the application and create new records in the database.
到目前为止,我能够运行该应用程序并在数据库中创建新记录。
However, I get the below error only when trying to update existing records;
但是,只有在尝试更新现有记录时才会出现以下错误;
Error committing transaction:
javax.ejb.TransactionRolledbackLocalException: Error committing transaction:
at weblogic.ejb.container.internal.EJBRuntimeUtils.throwTransactionRolledbackLocal(EJBRuntimeUtils.java:231)
at weblogic.ejb.container.internal.EJBRuntimeUtils.throwEJBException(EJBRuntimeUtils.java:134)
at weblogic.ejb.container.internal.BaseLocalObject.postInvoke1(BaseLocalObject.java:362)
at weblogic.ejb.container.internal.BaseLocalObject.__WL_postInvokeTxRetry(BaseLocalObject.java:205)
at weblogic.ejb.container.internal.SessionLocalMethodInvoker.invoke(SessionLocalMethodInvoker.java:46)
...
Caused by: weblogic.transaction.internal.AppSetRollbackOnlyException: setRollbackOnly called on transaction
The error happens when I call javax.persistence.EntityManager.merge(Object)
inside a Stateless EJB whose transactions are container managed.
当我javax.persistence.EntityManager.merge(Object)
在事务由容器管理的无状态 EJB 内部调用时,会发生错误。
My initial thoughts were that the container is calling javax.transaction.UserTransaction.setRollbackOnly()
somewhere, so I changed the EJB's transaction management to BMT and managed the transaction myself. The same error occurred.
我最初的想法是容器在javax.transaction.UserTransaction.setRollbackOnly()
某个地方调用,所以我将 EJB 的事务管理更改为 BMT 并自己管理事务。发生了同样的错误。
I suspect that my Datasource or persistence.xml have a problem.
我怀疑我的数据源或persistence.xml 有问题。
Below is my persistence.xml's properties
下面是我的persistence.xml 的属性
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="myunitname" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>myDS</jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.max_fetch_depth" value="1"/>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.WeblogicJtaPlatform"/>
</properties>
Please assist.
请协助。
回答by Alexandr Emelyanov
This is a default behaviour of Weblogic JTA realization. To obtain root exception you should set system property weblogic.transaction.allowOverrideSetRollbackReason
to true
.
这是 Weblogic JTA 实现的默认行为。要获得根异常,您应该将系统属性设置weblogic.transaction.allowOverrideSetRollbackReason
为true
.
One of the solution is add this line into <domain_home>/bin/setDomainEnv.cmd
:
解决方案之一是将此行添加到<domain_home>/bin/setDomainEnv.cmd
:
set JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.transaction.allowOverrideSetRollbackReason=true
set JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.transaction.allowOverrideSetRollbackReason=true
or linux equivalent into <domain_home>/bin/setDomainEnv.sh
或 linux 等价于 <domain_home>/bin/setDomainEnv.sh