geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@visi.com>
Subject Re: Stateful Session Bean Problem Geronimo 2.1.1: "Passivation Failed"
Date Thu, 10 Jul 2008 20:06:45 GMT

On Jul 10, 2008, at 1:05 AM, Mario Kofler wrote:

> hello,
>
> first, thanks a lot for helping out. of course the problem can lie in
> my application too, but as i reduced it to the most important parts, i
> cannot see where.
>
>> Are you using a Container-Managed EntityManager (i.e. looked up or  
>> injected) or a Bean-Managed EntityManager (created yourself via an  
>> EntityManagerFactory) ?
>
> can you maybe in two sentences tell me what is the big difference to
> use either of that two? i go via an entity manager factory, here is
> the relevant part of the code:

Here's the super terse version:

    @PersistenceContext(unitName="valhalla")
    private EntityManager em; // this object is a "fake". the real  
EntityManager lives in the transaction.  if no transaction, no  
EntityManager and no cached data holding memory.  pretty easy to  
passivate as there's nothing really "there" to passivate -- stateful  
beans can't be passivated in a transaction so all the hard stuff is  
avoided.

    @PersistenceUnit(unitName="valhalla")
    private EntityManagerFactory emf;
    private EntityManager em = emf.createEntityManager(); // this is  
an actual reference to an EntityManager created by the persistence  
provider.  it has a potentially large cache and hold potentially large  
amount of data.  if the persistence provider doesn't want it  
serialized, there's nothing we can do about it.

    @PersistenceContext(unitName="valhalla", type=EXTENDED)
    private EntityManager em; // fundamentally the same passivation- 
wise as bean-managed.  the real EntityManager lives for the life of  
the bean (not tied to a transaction like the first example).  a "fake"  
EntityManager is still involved, but there is a real one tied to the  
bean instance.  if the persistence provider doesn't want it  
serialized, there's nothing we can do about it.



-David



Mime
View raw message