2 Replies Latest reply on Sep 14, 2005 5:15 AM by Emmanuel Bernard

    4.0.3rc1: Exception trying to passivate StatefulBean

    Alan Berezin Newbie

      This is a continuation from another topic:

      The SessionBean that is having passivation problems has exactly one field:
      @PersistenceContext(unitName="dmdManager", type=PersistenceContextType.EXTENDED) EntityManager em;

      I only noticed running in debug mode in eclipse, single stepping for long enough for the timer to decide to passivate the bean. I might make a testcase outside eclipse to see what happens (if it is only an artifact of the dev environment, I dont care so much).

      It is this bean that has the problem bc I put a static logger message in a prepassivate method to confirm it is the offending bean (it is the only state bean in the app).

      I then modified the prepassivate method to flush the EntityManager. It seems that with that change, the bean passivates correctly. So, as the stack trace indicated, it appears that an open transaction cannot passivatge. Im I doing something dumb? Are open transactions not suppose to passivate? I realize that it might be bad design to hold open a database transaction by passivating (or other long running operations).


        • 1. Re: 4.0.3rc1: Exception trying to passivate StatefulBean
          Alan Berezin Newbie

          I the ejb draft spec says :

          In advanced cases, a session object?s conversational state may contain open resources, such as open
          sockets and open database cursors. A container cannot retain such open resources when a session bean
          instance is passivated. A developer of a stateful session bean must close and open the resources in the
          PrePassivate and PostActivate callback methods.[8]
          A container may only passivate a stateful session bean instance when the instance is not in a transaction.
          8) Note that this requirement does not apply to the EntityManager and EntityManagerFactory objects.

          Does this mean that jboss should passivate an unflushed EM?

          • 2. Re: 4.0.3rc1: Exception trying to passivate StatefulBean
            Emmanuel Bernard Master

            open tx cannot be passivated since they are linked to a connection usually.
            But unflushed em should be passivated.
            So if your tx are closed, the em can be passivated even if em hasn't been flushed yet.