Weblogic Error: Caused by: weblogic.transaction.internal.AppSetRollbackOnlyException: setRollbackOnly called on transaction

匿名 (未验证) 提交于 2019-12-03 01:23:02

问题:

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

org.hibernate.ejb.HibernatePersistencemyDS

Please assist.

回答1:

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 /bin/setDomainEnv.cmd:

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

or linux equivalent into /bin/setDomainEnv.sh



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!