openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Ezzio (JIRA)" <>
Subject [jira] Commented: (OPENJPA-684) Merge fails with context closed exception only when using load time "enhancement"
Date Fri, 29 Aug 2008 15:30:44 GMT


David Ezzio commented on OPENJPA-684:

I've run into the same test case failing with the same domain model in a different context
under different conditions.  I have not debugged the failure to determine whether it appears
to be the same reason for the failure.  Using WebLogic Server, with the service deployed in
a stateless session bean and the domain deployed as a PU contained within the bean, the failure
occurs even when both the server classes and the client classes have been enhanced by the
OpenJPA enhancer immediately after compilation.  To make the test case pass, I have found
that I must add the property 

<pre>&lt;property name="openjpa.DetachState" value="loaded(DetachedStateField=true)"

to persistence.xml.

I tested all eight combinations of these three 2-value conditions.  Here are my results:

Enhanced    Enhanced    Detached
classes     classes     State 
server      client      Field true   Works  Problem
    x           x           x          yes  -
    x           -           x           no  Expected: not serializable compatible
    x           x           -           no  Merge fails to update returned book
    x           -           -           no  Merge fails to update returned book
    -           x           -           no  Merge fails to update returned book
    -           -           -           no  Merge fails to update returned book
    -           x           x           no  Not serializable compatible, using 
                                            serialVersionUID may be workaround
    -           -           x           no  Expected: not serializable compatible

> Merge fails with context closed exception only when using load time "enhancement"
> ---------------------------------------------------------------------------------
>                 Key: OPENJPA-684
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>         Environment: Version 1.1.0, 1.x head, as of revision 684077.  Using Sun JVM version
1.5.0_14 and 1.6.0_05.
>            Reporter: David Ezzio
>         Attachments:
> A test class with four test methods passes when the model classes are enhanced at compile
time.  Three of the four test methods pass and one fails when the classes are enhanced at
load time.  The failure occurs when a context is closed exception is thrown:
> <openjpa-1.1.0-r422266:657916 fatal user error> org.apache.openjpa.persistence.InvalidStateException:
The context has been closed.  The stack trace at which the context was closed is held in the
embedded exception.
> FailedObject: java.lang.IllegalStateException
> 	at org.apache.openjpa.kernel.BrokerImpl.assertOpen(
> 	at org.apache.openjpa.kernel.BrokerImpl.beginOperation(
> 	at org.apache.openjpa.kernel.BrokerImpl.find(
> 	at org.apache.openjpa.kernel.BrokerImpl.find(
> 	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(
> 	at org.apache.openjpa.jdbc.sql.AbstractResult.load(
> 	at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(
> 	at org.apache.openjpa.jdbc.meta.strats.RelationToManyTableFieldStrategy.loadElement(
> 	at org.apache.openjpa.jdbc.meta.strats.RelationCollectionTableFieldStrategy.loadElement(
> 	at org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.load(
> 	at org.apache.openjpa.jdbc.meta.FieldMapping.load(
> 	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(
> 	at org.apache.openjpa.kernel.DelegatingStoreManager.load(
> 	at org.apache.openjpa.kernel.ROPStoreManager.load(
> 	at org.apache.openjpa.kernel.StateManagerImpl.loadFields(
> 	at org.apache.openjpa.kernel.StateManagerImpl.loadField(
> 	at org.apache.openjpa.kernel.StateManagerImpl.fetchObjectField(
> 	at org.apache.openjpa.kernel.StateManagerImpl.fetchField(
> 	at org.apache.openjpa.kernel.StateManagerImpl.fetch(
> 	at org.apache.openjpa.enhance.RedefinitionHelper$1.invoke(
> 	at $Proxy12.isEmpty(Unknown Source)
> 	at org.apache.openjpa.kernel.AttachStrategy.replaceCollection(
> 	at org.apache.openjpa.kernel.AttachStrategy.attachField(
> 	at org.apache.openjpa.kernel.VersionAttachStrategy.attach(
> 	at org.apache.openjpa.kernel.AttachManager.attach(
> 	at org.apache.openjpa.kernel.AttachManager.attach(
> 	at org.apache.openjpa.kernel.BrokerImpl.attach(
> 	at org.apache.openjpa.kernel.DelegatingBroker.attach(
> 	at org.apache.openjpa.persistence.EntityManagerImpl.merge(
> 	at org.apache.openjpa.persistence.spring.LibServiceImpl.returnBook(
> 	at org.apache.openjpa.persistence.spring.TestLibService.testReturnBook(
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> 	at java.lang.reflect.Method.invoke(
> 	at junit.framework.TestCase.runTest(
> 	at junit.framework.TestCase.runBare(
> 	at junit.framework.TestResult$1.protect(
> 	at junit.framework.TestResult.runProtected(
> 	at
> 	at
> 	at junit.framework.TestSuite.runTest(
> 	at
> 	at
> 	at
> 	at
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
> 	at
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
> Caused by: java.lang.IllegalStateException
> 	at
> 	at org.apache.openjpa.kernel.BrokerImpl.close(
> 	at org.apache.openjpa.kernel.DelegatingBroker.close(
> 	at org.apache.openjpa.persistence.EntityManagerImpl.close(
> 	at org.apache.openjpa.persistence.spring.LibServiceImpl.closeEM(
> 	at org.apache.openjpa.persistence.spring.LibServiceImpl.findBorrowerByName(
> 	at org.apache.openjpa.persistence.spring.TestLibService.testReturnBook(
> Debugging reveals that the issue is apparent confusion about which entity manager to
use when merging the detached entities.  The entity manager that makes the call to merge is
not the entity manager used when the failure occurs, but rather an entity manager that was
used previously and closed as expected.
> What is interesting about this test case is that it mimics the behavior of containers
(including the Spring Framework) that inject an entity manager at the beginning of each business
method (effectively) and close it at the end of the method.  Transactions are, of course,
handled within the short lifetime of the entity manager.

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

View raw message