Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejbRemove for a session bean

 
Deepti Sabarinath
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The EJB2.0 Specs mentions that "A timeout of client inactivity while the instance is in the passive state will result in the ejbRemove() method not being called". So what if the bean times out while it is in the method ready state ? Will ejbRemove() method be called then ? Is this mentioned in the specs any where ?
Thank you
Deepti
 
Sri Basavanahally
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In such a case the conatiner may call the ejbPassivate() method on the bean.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In EJB Spec2.0 See 7.6 Stateful Session bean state Diagram

I will it help you.
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Deepti Sabarinath:
The EJB2.0 Specs mentions that "A timeout of client inactivity while the instance is in the passive state will result in the ejbRemove() method not being called". So what if the bean times out while it is in the method ready state ? Will ejbRemove() method be called then ? Is this mentioned in the specs any where ?
Thank you
Deepti

Howdy
[yes, I'm once again alive and online after a loooong break finishing the book]
If the bean times out while method-ready, yes, the Container calls ejbRemove() to give the bean a chance, just as if the client had invoked remove() on the bean's component interface (or remove(handle) on the bean's remote home interface).
It's in the spec... don't have it in front of me to give you the actual page, but if you look in the session bean chapter, you'll find the lifecycle diagrams, and they show that you can have several paths to the "does not exist" state:
1) Client calls remove() on a stateful bean that's in the method-ready state, OR the bean times out while in the method-ready state, in which case Container calls ejbRemove() and then kills the bean
2) Client calls remove() on a stateful bean that's been passivated, OR the bean times out while passivated, in which case Container does NOT call ejbRemove(), but simply kills the bean
3) Bean throws a system exception (which for the bean, means any runtime exception including an EJBException) in which case, the Container logs the exception and kills the bean WITHOUT calling ejbRemove().
The exam indeed expects you to know the following ways in which a bean could MISS getting ejbRemove():
1) Container crashes
2) Bean times out while passivated
3) Bean throws a system exception
Hope that helps
p.s. The book has started to ship! I just got a copy from the publisher, so I've now held it in my hands. Amazon customers will be getting it first, and O'Reilly thinks that the Amazon pre-orders will go out within the next several days. It will not appear in stores for another week or two. The books are in the process of moving through warehouses and distribution channels.
Whew! Now I can finally go back to having fun and hanging out at the ranch.
cheers,
Kathy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic