Home > Hibernate, Seam, WebLogic > Caused by javax.persistence.TransactionRequiredException with message: “no transaction is in progress”

Caused by javax.persistence.TransactionRequiredException with message: “no transaction is in progress”

This is weird, I am not sure why I am getting it. I have an application that makes some calculations that take some considerable time, and I persist the results. I run my application with 100 records from the database and everything works fine. I run my application with 60.000 records from the database and I am getting the above error message. The exception happens when the flush() method is called on the EntityManager. If I am to have a wild guess I’d say that there is a transaction time out (it is set to 30 seconds in the weblogic console) and therefore when the flush() method is called there is no active transaction.

Anyway I managed to overcome this issue by explicitly defining a user transaction

import org.jboss.seam.transaction.Transaction;
import org.jboss.seam.transaction.UserTransaction;
...
...

UserTransaction ut = Transaction.instance();
ut.begin();
...
...
ut.commit();

If you have any idea why this is happening please leave a comment.

UPDATE: Now the first transaction (the one with 100 records) fails. It complains that there is already one transaction active when I try to start a new one. I guess I need to revert my code and to increase the transaction timeout on the weblogic console, this would solve both issues.

Advertisements
Categories: Hibernate, Seam, WebLogic
  1. 16 May 2011 at 6:48 am

    Thanks for the tutorial

  2. 12 October 2011 at 10:31 am

    Try using any third party Connection manager, set the trasaction properties to one which suits your type of application. Best way to handle connections and transactions.

    I had some other problems with respect to transaction. I used c3p0 but it didn’t work out later used DBCP and everything is working fine.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: