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.

Max Lam

Born and currently resides in Malaysia, a seasoned Java developer whom had held positions as Senior Developer, Consultant and Technical Architect in various enterprise software development companies.

Facebook Twitter LinkedIn Google+ 

Previous Posts

Building and Deploying Java EE EAR with Maven to Java EE Application Server (Part 2) – Where to put your source codes and pom.xml (EJB, MDB, Web & Enterprise Application Client)
Building and Deploying Java EE EAR with Maven to Java EE Application Server (Part 1) – Project Directory Structure & Module Generation Through archetype:generate

Building and Deploying Java EE EAR with Maven to Java EE Application Server (Part 1) - Project Directory Structure & Module Generation Through archetype:generate

December 1st, 2012

Maven wasn’t very popular and wide used when it was first released, but after version 2, it had ga[...]

Java LDAP/JNDI: 2 Ways Of Decoding And Using The objectGUID From Windows Active Directory

Java LDAP/JNDI: 2 Ways Of Decoding And Using The objectGUID From Windows Active Directory

October 13th, 2012

Windows Active Directory is a good way for many corporations to be used as a means of user managemen[...]

Quick Note: Unable To Perform LDAP Wildcard “*” Search On Windows Active Directory

Quick Note: Unable To Perform LDAP Wildcard "*" Search On Windows Active Directory

October 9th, 2012

In case you are searching high and low for a solution or an answer to why Windows Active Directory d[...]

Java JNDI/LDAP: Windows Active Directory Authentication, Organizational Unit, Group & Other Information Access

Java JNDI/LDAP: Windows Active Directory Authentication, Organizational Unit, Group & Other Information Access

October 4th, 2012

In today's IT environment, most mid-size corporation and above will have some form of centralized em[...]

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[...]