2 Replies Latest reply on Oct 3, 2005 3:24 AM by evrim

    stateful bean passivation problem is unclear

    evrim

      Hi,

      I'm trying to avoid the problem noted here: http://jira.jboss.com/jira/browse/EJBTHREE-231
      I'm using jboss 4.0 branch cvs version.

      When i make context transient, never injected again after activation so i'm getting into NPE while ctx.getRemoteUser(). If i don't make it transient, jboss rushes to serialize it to disk with a %100 load. After serialization, %100 load don't go away.

      Do i also have to make entitymanager transient? I'm also having trouble about how to flush() entity manager inside prePassivate(). I couldn't made the method transactional.

      Thx.
      Evrim.

        • 1. Re: stateful bean passivation problem is unclear
          evrim

          i've got some answers from spec, summarizing here in order to double check:

          Ejb3-spec-ejbcore says: (page 58)

          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 bean must close and open the resources in the PrePassivate and PostActive(subnote 8)

          And subnote 8 reads:
          Note that this requirement does not apply to the EntityManager and EntityManagerFactory objects.

          So, any stateful session bean developer does not have to flush() or do something inside @PrePassivate.

          Is this true for jboss4,ejb3?

          • 2. Re: stateful bean passivation problem is unclear
            evrim

            More answers (my lucky day):

            Ejb3-spec-ejbcore reads: (page 59)

            The bean provider must assume that the content of transient fields may be lost between PrePassivate and PostActivate notifications. There, the bean provider should not store in a transient field a references to any of the following objects: SessionContext object; environment JNDI naming context and any its subcontexts; business interfaces; home and component interfaces; EntityManager interface; EntityManagerFactory interface; UserTransaction interface.

            Ok. i've learned that they won't be transient. Same question: Is this legal for jboss4/ejb3?

            My last problem is hibernate load while passivation. Let me try to re-attack the problem.