Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 498
mwangi Avatar asked Dec 19 '22 02:12

mwangi


1 Answers

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

like image 103
Alexandr Emelyanov Avatar answered Jan 18 '23 23:01

Alexandr Emelyanov