Weblogic error: caused by: weblogic.transaction.internal.AppSetRollbackOnlyException: setRollbackOnly caused by transaction

I am migrating an application from Jboss 7as to Weblogic 12c.

So far, I could run the application and create new records in the database.

However, I get the following 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 occurs when I call javax.persistence.EntityManager.merge(Object) inside an stateless object whose transactions are managed by the container.

My initial thoughts were that the container calls javax.transaction.UserTransaction.setRollbackOnly() somewhere, so I changed the EJB transaction management to BMT and managed the transaction myself. The same error occurred.

I suspect my Datasource or persistence.xml has problems.

Below are my persistence.xml 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, help.

+2
source share
1 answer

This is the default behavior for implementing JTA Weblogic. To get a root exception, you must set the weblogic.transaction.allowOverrideSetRollbackReason system property to true .

One solution is to add this line to <domain_home>/bin/setDomainEnv.cmd :

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

or the linux equivalent in <domain_home>/bin/setDomainEnv.sh

+5
source

Source: https://habr.com/ru/post/1301039/


All Articles