// you're reading...

Quick Fix: Weblogic 10.3.x – How To Solve “org.apache.openjpa.persistence.
InvalidStateException: Detected reentrant flush…”

I was performing a Java EE App migration to Weblogic 10.3.6, that worked very well in other Java EE Application Servers. The Java EE App runs on MySQL DB. Unfortunately, there was this annoying little problem that caused the whole application to fail. Everytime when I deploy the EAR, it gives an exception stack like the below:

...
Exception in thread "main"  org.apache.openjpa.persistence.InvalidStateException: Detected reentrant
flush. Make sure your flush-time instance callback methods or event listeners do not invoke any
operations that require the in-progress flush to complete.
at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2033) 
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1808) 
at org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:609)
...

Note:
It doesn't happen on Weblogic 12c. Only Weblogic 10.3.x is affected.

Well, you get the idea…

While searching on Google, I’ve found a bug report on OpenJPA: link, which indeed it has yet to be fixed at the time of this writing.

If that’s the problem, how did I fixed it?

Solution:

As I checked on the entity classes and discovered that the primary key/ID field was furnished with the annotation like the below:

 Java(TM) 2 Platform Standard Edition 5.0 |  copy code |? 
01
@Entity
02
@Table( name = "SOME_TABLE" )
03
public class SomeEntityModel implements Serializable {
04
 
05
    // ... The rest of the code ...
06
    @Id
07
    @GeneratedValue( strategy = GenerationType.IDENTITY )
08
    @Basic( optional = false )
09
    @Column( name = "PK" )
10
    private Long pk;
11
    // ... The rest of the code ...
12
 
13
}

If you have an entity annotations like these, the problem actually lies on the “@Basic( optional = false )“. All you need to do is to remove that and have something very simple like this:

@Id
@GeneratedValue( strategy = GenerationType.IDENTITY )
@Column( name = "PK" )
private Long pk;

You are good to go. Problem solved. Hopefully, this piece of info could help someone out there to avoid such a pitfall.

Previous Posts

MySQL Cluster NDB 7.2 on Solaris 10 Part 3 – Testing The Cluster

MySQL Cluster NDB 7.2 on Solaris 10 Part 3 - Testing The Cluster

September 22nd, 2012

We are back again to have fun with our cluster that we've setup written in our previous articles on [...]

MySQL Cluster NDB 7.2 on Solaris 10 Part 2 – Starting, Distributed Synchronized Users Management And Stopping The Cluster

MySQL Cluster NDB 7.2 on Solaris 10 Part 2 - Starting, Distributed Synchronized Users Management And Stopping The Cluster

September 18th, 2012

This is the continuation from the previous part of the tutorial MySQL Cluster NDB 7.2 on Solaris 10 [...]

MySQL Cluster NDB 7.2 on Solaris 10 Part 1 – How To Install, Setup and Configure

MySQL Cluster NDB 7.2 on Solaris 10 Part 1 - How To Install, Setup and Configure

September 18th, 2012

If you have landed on this page, we believe you might either had a bumpy ride in getting the MySQL c[...]

Quick Fix: How to Solve “Unable to read the logging configuration” on Netbeans7 with JBoss6

Quick Fix: How to Solve "Unable to read the logging configuration" on Netbeans7 with JBoss6

September 8th, 2012

This is just a quick fix post for those whom are having this problem when running JBoss 6.x with Net[...]

Making sense of EJB3.x Transaction Attributes – Part 4 (NEVER)

Making sense of EJB3.x Transaction Attributes – Part 4 (NEVER)

September 5th, 2012

This is the last part in the series of "Making sense of EJB3.x Transaction Attributes". So far, we'v[...]

Making sense of EJB3.x Transaction Attributes – Part 3 (Difference Between SUPPORTS and NOT_SUPPORTED)

Making sense of EJB3.x Transaction Attributes – Part 3 (Difference Between SUPPORTS and NOT_SUPPORTED)

September 5th, 2012

Oracle had extensively documented the behavior of each transaction attributes in the Java EE documen[...]

Making sense of EJB3.x Transaction Attributes – Part 2 (MANDATORY)

Making sense of EJB3.x Transaction Attributes - Part 2 (MANDATORY)

April 17th, 2012

In my previous post, we've discussed about TransactionAttributeType.REQUIRES_NEW: how it behaves and[...]

Making sense of EJB3.x Transaction Attributes – Part 1 (REQUIRES_NEW)

Making sense of EJB3.x Transaction Attributes - Part 1 (REQUIRES_NEW)

March 29th, 2012

For the previous past posts, I have dealth much with manual fine-grind transaction, mostly on the su[...]

EJB3.x JPA: When to use rollback() and setRollbackOnly()

EJB3.x JPA: When to use rollback() and setRollbackOnly()

March 23rd, 2012

After JTA was introduced for more than a decade ago, then later with the introduction of Bean-Manage[...]