openjpa-dev mailing list archives

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

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

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

<property name="openjpa.DetachState" value="loaded(DetachedStateField=true)" />

to persistence.xml.

I tested all eight combinations of these three 2-value conditions. My results are attached.


> Merge fails with context closed exception only when using load time "enhancement"
> ---------------------------------------------------------------------------------
>
>                 Key: OPENJPA-684
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-684
>             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: OPENJPA-684-Failing-Test-Case.zip
>
>
> 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(BrokerImpl.java:4360)
> 	at org.apache.openjpa.kernel.BrokerImpl.beginOperation(BrokerImpl.java:1763)
> 	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:793)
> 	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:774)
> 	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:811)
> 	at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:258)
> 	at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2228)
> 	at org.apache.openjpa.jdbc.meta.strats.RelationToManyTableFieldStrategy.loadElement(RelationToManyTableFieldStrategy.java:82)
> 	at org.apache.openjpa.jdbc.meta.strats.RelationCollectionTableFieldStrategy.loadElement(RelationCollectionTableFieldStrategy.java:75)
> 	at org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.load(StoreCollectionFieldStrategy.java:479)
> 	at org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:802)
> 	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:520)
> 	at org.apache.openjpa.kernel.DelegatingStoreManager.load(DelegatingStoreManager.java:116)
> 	at org.apache.openjpa.kernel.ROPStoreManager.load(ROPStoreManager.java:78)
> 	at org.apache.openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java:2911)
> 	at org.apache.openjpa.kernel.StateManagerImpl.loadField(StateManagerImpl.java:2989)
> 	at org.apache.openjpa.kernel.StateManagerImpl.fetchObjectField(StateManagerImpl.java:2238)
> 	at org.apache.openjpa.kernel.StateManagerImpl.fetchField(StateManagerImpl.java:775)
> 	at org.apache.openjpa.kernel.StateManagerImpl.fetch(StateManagerImpl.java:737)
> 	at org.apache.openjpa.enhance.RedefinitionHelper$1.invoke(RedefinitionHelper.java:230)
> 	at $Proxy12.isEmpty(Unknown Source)
> 	at org.apache.openjpa.kernel.AttachStrategy.replaceCollection(AttachStrategy.java:292)
> 	at org.apache.openjpa.kernel.AttachStrategy.attachField(AttachStrategy.java:221)
> 	at org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAttachStrategy.java:161)
> 	at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:241)
> 	at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:101)
> 	at org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3206)
> 	at org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBroker.java:1158)
> 	at org.apache.openjpa.persistence.EntityManagerImpl.merge(EntityManagerImpl.java:769)
> 	at org.apache.openjpa.persistence.spring.LibServiceImpl.returnBook(LibServiceImpl.java:188)
> 	at org.apache.openjpa.persistence.spring.TestLibService.testReturnBook(TestLibService.java:196)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at junit.framework.TestCase.runTest(TestCase.java:168)
> 	at junit.framework.TestCase.runBare(TestCase.java:134)
> 	at junit.framework.TestResult$1.protect(TestResult.java:110)
> 	at junit.framework.TestResult.runProtected(TestResult.java:128)
> 	at junit.framework.TestResult.run(TestResult.java:113)
> 	at junit.framework.TestCase.run(TestCase.java:124)
> 	at junit.framework.TestSuite.runTest(TestSuite.java:232)
> 	at junit.framework.TestSuite.run(TestSuite.java:227)
> 	at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76)
> 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: java.lang.IllegalStateException
> 	at org.apache.openjpa.kernel.BrokerImpl.free(BrokerImpl.java:4138)
> 	at org.apache.openjpa.kernel.BrokerImpl.close(BrokerImpl.java:4068)
> 	at org.apache.openjpa.kernel.DelegatingBroker.close(DelegatingBroker.java:1298)
> 	at org.apache.openjpa.persistence.EntityManagerImpl.close(EntityManagerImpl.java:1106)
> 	at org.apache.openjpa.persistence.spring.LibServiceImpl.closeEM(LibServiceImpl.java:42)
> 	at org.apache.openjpa.persistence.spring.LibServiceImpl.findBorrowerByName(LibServiceImpl.java:129)
> 	at org.apache.openjpa.persistence.spring.TestLibService.testReturnBook(TestLibService.java:188)
> 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.


Mime
View raw message