0 Replies Latest reply on Apr 9, 2003 5:59 AM by dirk.haase

    when to remove() Stateful Session Beans?

    dirk.haase

      Hi,

      I was curious when I had to call remove() on a stateful session bean. I have following different scenarios where a client calls methods on a stateful session bean. Please let me know if I don't do the clean-up correctly.

      1) Stateful CMT session. Method call works fine. I call session.remove() when I don't need the session anymore.

      2) Stateful CMT session. Method threw an Application Exception. I suppose the Transaction is rolled back and the session invalidated since it may be in an uncosistent state. I just do session = null; since I assume the session is already removed.

      3) Stateful CMT Session. Method threw a RuntimeException. ...same as 2).

      4) Stateful BMT Session. The session starts a new Transaction. Application Method works fine. I commit the Transaction and call session.remove() when I am done.

      5) Stateful BMT Session. The session starts a new Transaction. Application Method works fine. I still (because I feel like it) roll back the Transaction and call session.remove().


      6) Stateful BMT Session. The session starts a new Transaction and then a Method is called which throws an ApplicationException. I call rollBack and then session.remove().

      7) Stateful BMT Session. I start a new Transaction. An Application Method in the Stateful Session throws a RuntimeException to the client. I assume that the Transaction is rolled back and only set session = null; since the Session should be invalidated.

      8) Stateful BMT Session starts a Transaction and then calls a method in a stateless CMT Session which throws a RuntimeException. The Stateful BMT Session wraps the RuntimeException in an ApplicationException and throws it to the client. I assume that the Transaction is rolled back since it passed the inerceptor stack of the stateless CMT Session. But what about the stateful BMT Session? I suppose I don't need to rollBack the transaction anymore, but need to call remove(). Am I right there?

      I would appreciate if you could comment on some or all of the scenarios. I fear that I have some old Stateful Session Bean relicts in my server that never get removed.

      thanks for your help,
      Dirk