Weblogic 错误:由:weblogic.transaction.internal.AppSetRollbackOnlyException:setRollbackOnly 调用事务 [英] Weblogic Error: Caused by: weblogic.transaction.internal.AppSetRollbackOnlyException: setRollbackOnly called on transaction

查看:33
本文介绍了Weblogic 错误:由:weblogic.transaction.internal.AppSetRollbackOnlyException:setRollbackOnly 调用事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一个应用程序从 Jboss 7as 移植到 Weblogic 12c.

I am porting an application from Jboss 7as to 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

当我在事务由容器管理的无状态 EJB 中调用 javax.persistence.EntityManager.merge(Object) 时发生错误.

The error happens when I call javax.persistence.EntityManager.merge(Object) inside a Stateless EJB whose transactions are container managed.

我最初的想法是容器在某处调用了 javax.transaction.UserTransaction.setRollbackOnly(),所以我将 EJB 的事务管理更改为 BMT 并自己管理事务.发生了同样的错误.

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.

我怀疑我的数据源或persistence.xml 有问题.

I suspect that my Datasource or persistence.xml have a problem.

下面是我的persistence.xml的属性

Below is my persistence.xml's properties

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

请帮忙.

推荐答案

这是 Weblogic JTA 实现的默认行为.要获得根异常,您应该将系统属性 weblogic.transaction.allowOverrideSetRollbackReason 设置为 true.

This is a default behaviour of Weblogic JTA realization. To obtain root exception you should set system property weblogic.transaction.allowOverrideSetRollbackReason to true.

解决方案之一是将这一行添加到/bin/setDomainEnv.cmd:

One of the solution is add this line into <domain_home>/bin/setDomainEnv.cmd:

set JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.transaction.allowOverrideSetRollbackReason=true

或 linux 等价于 /bin/setDomainEnv.sh

or linux equivalent into <domain_home>/bin/setDomainEnv.sh

这篇关于Weblogic 错误:由:weblogic.transaction.internal.AppSetRollbackOnlyException:setRollbackOnly 调用事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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