Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Transaction in Session Bean

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

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..

SCJP 1.3
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Hope that's correct & helps...

Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi SamyV,

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.

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
    Bookmark Topic Watch Topic
  • New Topic