[ https://issues.apache.org/jira/browse/OPENJPA-102?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12465355 ]
Patrick Linskey commented on OPENJPA-102: ----------------------------------------- openjpa-detach.patch solves the described issue, but exposes another issue: an ObjectNotFoundException will be thrown during a subsequent BrokerImpl.close() call. The attached patch calls free() with Status.NO_TRANSACTION if BrokerImpl.close() is invoked. The use case at hand seems to do the following: 1. UserTransaction.begin() 2. getReference() on a nonexistant record 3. close() in a session bean 4. UserTransaction.commit(), which fails With the patch, BrokerImpl.afterCompletion() calls BrokerImpl.free(Status.STATUS_ROLLEDBACK) from line 1789, because close had been invoked. The patch makes that free() invocation work as expected. However, close() is being invoked later on. This later invocation is probably erroneous, but currently it is causing OpenJPA to throw an exception from BrokerImpl.java:3984, because close() calls free() with Status.NO_TRANSACTION. I believe that OpenJPA should be short-circuiting close() if isClosed() returns true, or that free() should short-circuit if isClosed() returns true. > JTA transaction rollback, nonexistant instances, transactional persistence > context => failures during afterCompletion() and close() > ----------------------------------------------------------------------------------------------------------------------------------- > > Key: OPENJPA-102 > URL: https://issues.apache.org/jira/browse/OPENJPA-102 > Project: OpenJPA > Issue Type: Bug > Components: jpa, kernel > Environment: WebLogic Server 10.0 > Reporter: Patrick Linskey > Attachments: openjpa-detach.patch > > > Configuration: > - transactional persistence context > - DetachState=fgs > - JTA transactions > If an error causes the transaction manager to roll back the current > transaction, BrokerImpl.afterCompletion() will be invoked with > Status.STATUS_ROLLEDBACK. afterCompletion() will call BrokerImpl.free(), > which will attempt to load the default fetch group. If there is an instance > in the Broker's context that does not exist (that was looked up via > EntityManager.getReference(), for example), then the code in free() will fail > with an ObjectNotFoundException. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira