Container managed transaction & the remove() method


EJB programming & troubleshooting: Container managed transaction & the remove() method

  1. Container managed transaction & the remove() method (1 messages)

    Can anyone help me with two J2EE questions.

    The first is to do with container managed transactions. Since a container managed transaction is managed by the container (that much I understand!) what happens if an invocation of con.commit() method occurs in the program code? Is this simply ignored since the transaction is managed by the container?

    The second query is with regards to invoking remove() on a stateless session bean.

    My understanding is that when you invoke create() on a stateless session beans home interface it creates an ejb object on the server (which implements the remote interface on the server) and returns a reference to the client. The client can then invoke methods on the returned stub and for each method a bean is swapped into the ejb object from the instance pool, services the request, and then is placed back into the instance pool.
    Then when the client invokes remove() the EJB OBJECT is removed from the server.

    What I would like to know is what happens to the EJB OBJECT if the client doesn't invoke remove()? Is it automatically garbage collected after some period of inactivity?

    Any help anyone could provide would be appreciated.

    Thank you!
  2. Runtime error/no remove[ Go to top ]

    Calling commit or rollback will cause a java.sql.SQLException, since JDBC will be aware that the transaction has been started at a higher level than the connection as part of a distributed transaction.

    You don't ever call remove() on SLSBs - this is for SFSBs only. When the method has completed, the container will return the stateless bean to the bean pool, ready for another call. Member variables will remain in tact.

    Best wishes
    Adrian O'Sullivan