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

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

问题描述



到目前为止,我能够运行应用程序并在数据库中创建新记录。

p>

但是,只有在尝试更新现有记录时,才会收到以下错误信息;

 提交事务时出错:
javax.ejb.TransactionRolledbackLocalException:提交事务时出错:
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)
...
引起:weblogic .transaction.internal.AppSetRo llbackOnlyException:setRollbackOnly调用事务

当我调用 javax.persistence时发生错误.EntityManager.merge(Object)在一个无状态的EJB里面,它的事务是通过容器管理的。



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



我怀疑我的Datasource或persistence.xml有问题。



下面是我的persistence.xml的属性

 <持久性版本=2.0
xmlns =http://java.sun.com/xml / ns / persistencexmlns: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 =myunitnametransaction-type =JTA>
< provider> org.hibernate.ejb.HibernatePersistence< / provider>
< jta-data-source> myDS< / jta-data-source>
<属性>
< property name =hibernate.hbm2ddl.autovalue =update/>
< property name =hibernate.show_sqlvalue =false/>
< property name =hibernate.format_sqlvalue =false/>
< property name =hibernate.dialectvalue =org.hibernate.dialect.Oracle10gDialect/>
< property name =hibernate.max_fetch_depthvalue =1/>
< property name =hibernate.transaction.jta.platformvalue =org.hibernate.service.jta.platform.internal.WeblogicJtaPlatform/>
< / properties>

请协助。

解决方案

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



其中一个解决方案是将此行添加到< domain_home> /bin/setDomainEnv.cmd








$ p








$ b $相当于< domain_home> /bin/setDomainEnv.sh


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

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

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.

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

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>

Please assist.

解决方案

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

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

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

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

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

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