openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Caspar MacRae (JIRA)" <>
Subject [jira] [Commented] (OPENJPA-1677) "InvalidStateException: Detected reentrant flush..." while building an error message for an earlier exception
Date Wed, 31 Oct 2012 11:45:11 GMT


Caspar MacRae commented on OPENJPA-1677:

This is happening to me on a Temporal column that is autogenerated by the dB, which then triggers
a toString() -> hashCode() -> id chain.

<openjpa-2.2.0-r422266:1244990 fatal user error> org.apache.openjpa.persistence.InvalidStateException:
The field "xxx" of instance "why_are_you_calling_toString" contained a null value; the metadata
for this field specifies that nulls are illegal.

The model works fine with other JPA providers, so I can only conclude that temporal definition
is correct and I'm being hit by simultaneous OpenJpa bugs - the fact that this 2 years old,
unassigned and not marked critical gives me cause for concern.
> "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
>         Attachments:
> 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.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message