openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Caspar MacRae (JIRA)" <j...@apache.org>
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

    [ https://issues.apache.org/jira/browse/OPENJPA-1677?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13487687#comment-13487687
] 

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: https://issues.apache.org/jira/browse/OPENJPA-1677
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.0.0
>            Reporter: Vermeulen
>         Attachments: openjpa-1677_sscce.zip
>
>
> 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
me.
> 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(BrokerImpl.java:2033)
> 	at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1808)
> 	at org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:609)
> 	at org.apache.openjpa.kernel.StateManagerImpl.assignField(StateManagerImpl.java:696)
> 	at org.apache.openjpa.kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1608)
> 	at org.apache.openjpa.kernel.StateManagerImpl.accessingField(StateManagerImpl.java:1591)
> 	at entities.TestEntity.pcGetid(TestEntity.java)
> 	at entities.TestEntity.toString(TestEntity.java:34)
> 	at java.text.MessageFormat.subformat(MessageFormat.java:1246)
> 	at java.text.MessageFormat.format(MessageFormat.java:836)
> 	at java.text.Format.format(Format.java:140)
> 	at java.text.MessageFormat.format(MessageFormat.java:812)
> 	at org.apache.openjpa.lib.util.Localizer$Message.getMessage(Localizer.java:277)
> 	at org.apache.openjpa.util.OpenJPAException.<init>(OpenJPAException.java:64)
> 	at org.apache.openjpa.util.UserException.<init>(UserException.java:47)
> 	at org.apache.openjpa.util.InvalidStateException.<init>(InvalidStateException.java:34)
> 	at org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:553)
> 	at org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:491)
> 	at org.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.java:2957)
> 	at org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:40)
> 	at org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:1047)
> 	at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2077)
> 	at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2037)
> 	at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1955)
> 	at org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
> 	at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1479)
> 	at org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:925)
> 	at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:559)
> 	at MinimalExample.saveInTransaction(MinimalExample.java:41)
> 	at MinimalExample.failingExample(MinimalExample.java:29)
> 	at MinimalExample.main(MinimalExample.java:15)
> 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: http://www.atlassian.com/software/jira

Mime
View raw message