openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vermeulen (JIRA)" <>
Subject [jira] Commented: (OPENJPA-1677) "InvalidStateException: Detected reentrant flush..." while building an error message for an earlier exception
Date Wed, 02 Jun 2010 16:21:27 GMT


Vermeulen commented on OPENJPA-1677:

Even worse, when I first merge a new entity that has the required OneToMany relation set,
the reentrant flush exception goes away...

I will soon attach an SSCCE which can be built with Maven and shows the problem.

> "InvalidStateException: Detected reentrant flush..." while building an error message
for an earlier exception
> -------------------------------------------------------------------------------------------------------------
>                 Key: OPENJPA-1677
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.0.0
>            Reporter: Vermeulen
> This error seems to only seems turn up when several criteria are met...
> I am calling entityManager.merge for a new entity that has a required ManyToOne field
set to null. This naturally gives an error like "org.apache.openjpa.persistence.InvalidStateException:
The field "test" of instance "TestEntity " contained a null value; the metadata for this field
specifies that nulls are illegal."
> But under certain circumstances, while building the error message of this error a new
error occurs which masks the original error message. This message is extremely confusing to
> When OpenJPA builds the error message for the original InvalidStateException it seems
to call the toString() method of my entity, which in it's turn gives the "Detected reentrant
flush" when:
>  1) inside the toString() method of my entity I acces the id field
>  2) the id field is annotated with @GeneratedValue(strategy = GenerationType.IDENTITY)
> The stack trace I get is:
> Exception in thread "main" <openjpa-2.0.0-r422266:935683 fatal user error> 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(
> 	at org.apache.openjpa.kernel.BrokerImpl.flush(
> 	at org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(
> 	at org.apache.openjpa.kernel.StateManagerImpl.assignField(
> 	at org.apache.openjpa.kernel.StateManagerImpl.beforeAccessField(
> 	at org.apache.openjpa.kernel.StateManagerImpl.accessingField(
> 	at entities.TestEntity.pcGetid(
> 	at entities.TestEntity.toString(
> 	at java.text.MessageFormat.subformat(
> 	at java.text.MessageFormat.format(
> 	at java.text.Format.format(
> 	at java.text.MessageFormat.format(
> 	at org.apache.openjpa.lib.util.Localizer$Message.getMessage(
> 	at org.apache.openjpa.util.OpenJPAException.<init>(
> 	at org.apache.openjpa.util.UserException.<init>(
> 	at org.apache.openjpa.util.InvalidStateException.<init>(
> 	at org.apache.openjpa.kernel.SingleFieldManager.preFlush(
> 	at org.apache.openjpa.kernel.SingleFieldManager.preFlush(
> 	at org.apache.openjpa.kernel.StateManagerImpl.preFlush(
> 	at org.apache.openjpa.kernel.PNewState.beforeFlush(
> 	at org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(
> 	at org.apache.openjpa.kernel.BrokerImpl.flush(
> 	at org.apache.openjpa.kernel.BrokerImpl.flushSafe(
> 	at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(
> 	at org.apache.openjpa.kernel.LocalManagedRuntime.commit(
> 	at org.apache.openjpa.kernel.BrokerImpl.commit(
> 	at org.apache.openjpa.kernel.DelegatingBroker.commit(
> 	at org.apache.openjpa.persistence.EntityManagerImpl.commit(
> 	at MinimalExample.saveInTransaction(
> 	at MinimalExample.failingExample(
> 	at MinimalExample.main(
> Why is OpenJPA calling the toString() method anyway, this seems to be dangerous...
> This second error goes away and I get the original error when I either remove the access
tot the id field inside my toString() method or when I simply use @GeneratedValue with the
default strategy.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message