You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Jean-Louis MONTEIRO <je...@gmail.com> on 2011/07/11 09:44:21 UTC

EntityManager not closed when a stateful is destroyed

Hello,

I guess there is an issue with the stateful container.
Actually, when a @Remove method is invoke, all attached persistence context
must be closed as per the spec.

*7.6.2 Container-managed Extended Persistence Context*

A container-managed extended persistence context can only be initiated
within the scope of a stateful

session bean. It exists from the point at which the stateful session bean
that declares a dependency on an

entity manager of type PersistenceContextType.EXTENDED is created, and is
said to be bound

to the stateful session bean. The dependency on the extended persistence
context is declared by means

of the PersistenceContext annotation or persistence-context-ref deployment
descrip-

tor element.

The persistence context is closed by the container when the @Remove method
of the stateful session

bean completes (or the stateful session bean instance is otherwise
destroyed).



*3.2.7 Detached Entities*

A detached entity results from transaction commit if a transaction-scoped
container-managed entity

manager is used (see section 3.3); from transaction rollback (see section
3.3.2); from detaching the

entity from the persistence context; from clearing the persistence context;
from closing an entity man-

ager; or from serializing an entity or otherwise passing an entity by
value—e.g., to a separate applica-

tion tier, through a remote interface, etc.


After checking the StatefulContainer, i saw the following comment  // todo
destroy extended persistence contexts
For the moment, Persistence Context are released but not closed.

I want to fix that, but would like to get your thoughts.
BTW, in the #removeEJBObject method, I guess I must close persistence
contexts after the afterInvoke method.

Jean-Louis

Fwd: EntityManager not closed when a stateful is destroyed

Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
FYI

If something fails in Geronimo, please lemme know.

Jean-Louis

---------- Forwarded message ----------
From: Jean-Louis MONTEIRO <je...@gmail.com>
Date: 2011/7/12
Subject: Re: EntityManager not closed when a stateful is destroyed
To: dev@openejb.apache.org


OK, reverted changes yesterday because of an issue with Inherited
Persistence
Context.
Just committed another version with some more tests.
Everything works on my laptop and on the CI.

Jean-Louis



--
View this message in context:
http://openejb.979440.n4.nabble.com/EntityManager-not-closed-when-a-stateful-is-destroyed-tp3658876p3662008.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Re: EntityManager not closed when a stateful is destroyed

Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
OK, reverted changes yesterday because of an issue with Inherited Persistence
Context.
Just committed another version with some more tests.
Everything works on my laptop and on the CI.

Jean-Louis



--
View this message in context: http://openejb.979440.n4.nabble.com/EntityManager-not-closed-when-a-stateful-is-destroyed-tp3658876p3662008.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Re: EntityManager not closed when a stateful is destroyed

Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
Here is the related JIRA.
https://issues.apache.org/jira/browse/OPENEJB-1628

Will commit some changes.
Have a look if possible.

Jean-Louis

--
View this message in context: http://openejb.979440.n4.nabble.com/EntityManager-not-closed-when-a-stateful-is-destroyed-tp3658876p3659032.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.