File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Stateless session bean ejbRemove() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Stateless session bean ejbRemove()" Watch "Stateless session bean ejbRemove()" New topic

Stateless session bean ejbRemove()

Adri Smith
Ranch Hand

Joined: Jun 07, 2004
Posts: 76
Hi all,

I am actually kind of confused with the method ejbRemove(). I am wondering when exactly this method is called in case of a stateless session bean.

I would like to know if this method is called when the user call remove on the component interface or if it is called when the instance is killed from the pool. My guess is that is never called when the user call the remove method because the bean returns to the pool after each business call and therefore the client EJBObject never keeps a reference to the bean.

Thanks in advance,
Sanju Thomas
Ranch Hand

Joined: Dec 29, 2004
Posts: 243
Yes, You are right. ejbRemove() method is never going to be called when the user invoke the remove method in the component interface. ejbRemove() method will be invoked by the container, when it need to reduce the size of the instance pool. So client will have no role in removing the bean instance from the pool. After each business method invocation the bean instance will go back to the pool.

Hope, this will help you.
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
For stateless session beans, the clients do not have control over when the beans are created or destroyed. In the case of ejbCreate, the container will only invoke this method when the client invoke a business method. Likewise, the container decides when to call ejbRemove independently of the client.

SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
Adri Smith
Ranch Hand

Joined: Jun 07, 2004
Posts: 76
Thanks a lot to both for your responses.

This is definitely makes it clearer in my mind

Good luck if you are still preparing for the SCBCD
[ April 19, 2005: Message edited by: Adri Smith ]
I agree. Here's the link:
subject: Stateless session bean ejbRemove()
It's not a secret anymore!