Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 4680 invoked from network); 29 Aug 2008 15:37:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Aug 2008 15:37:37 -0000 Received: (qmail 31585 invoked by uid 500); 29 Aug 2008 15:37:34 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 31550 invoked by uid 500); 29 Aug 2008 15:37:34 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 31526 invoked by uid 99); 29 Aug 2008 15:37:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Aug 2008 08:37:34 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Aug 2008 15:36:45 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 6BEAF234C1C8 for ; Fri, 29 Aug 2008 08:36:45 -0700 (PDT) Message-ID: <321443086.1220024205440.JavaMail.jira@brutus> Date: Fri, 29 Aug 2008 08:36:45 -0700 (PDT) From: "David Ezzio (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Updated: (OPENJPA-684) Merge fails with context closed exception only when using load time "enhancement" In-Reply-To: <177316215.1218224144283.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-684?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] David Ezzio updated OPENJPA-684: -------------------------------- Attachment: results.zip Results of testing with openjpa.DetachState on WebLogic Server 10.3 > 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, results.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: > 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.