I am preparing for the SCBCD and planning to sit for the exam on the Java Certification Day here in Singapore. I have got a doubt as below.
Referring to page 207 of HeadFirst EJB, under the list of use your session context to i could find 'get a transaction reference and call methods on it (BMT Beans)'. But methods on CMT like force a transaction to rollback and find out whether a transaction has already been rolled back could not be called. How can this be explained? When a bean is in a transaction it cannot be passivated. Isn't this applies to both CMT and BMT? Thanks for any replies..
I think I know the answer to the second question: Stateful session beans can only keep a transaction open over more than one method invokation when using BMT. With CMT, the transaction has to be completed within the method. Since the container will not attempt to passivate the bean while it is in the middle of a business method (but only when the bean has not been used for some time), this problem will not occur with CMT.
I think the answer for your question is on page 499 of HF EJB. CMT session bean methods ejbCreate(), ejbRemove(), ejbActivate() and ejbPassivate() run in an "unspecified transaction context". In other words, the create and remove methods os session bean are not considered part of client's transaction and activate and passivate will never be called if the session bean is in a trasaction. Remember it is true for CMT session beans. I hope this helps you.
SCJA, SCJP, SCBCD & SCEA (Part I)
Beware the other head of science - it bites! Nibble on this message:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop