Howdy -- for stateFUL session beans, the container will treat a remove() method as a business method, and "wake up" the bean to invoke the ejbRemove() method (so ejbActivate() will be called first).
When a bean times out while passivated, the container does NOT "wake up" the bean, because it knows that the relationship between this bean and this client is already OVER, as far as the container is concerned, so there is nothing else to be done.
But the container treats a remove() call as something active from the client -- something that means the client/bean relationship is still alive and well, even if the remove() means "Hey bean, I'm done with you now... so complete my conversation with you... finish my session." and the bean may do something *related to that client*.
So the big question is about WHERE do you do your cleanup, and you still must assume that ejbRemove() might not be called (because of all the other issues -- server crash, timeout while passivated, system exception) so, here would be my advice:
* Do NOT rely on ejbRemove() for your clean up.
* Do NOT assume ejbRemove() will be called.
* Use ejbRemove() for extra client-session-specific things that you want to do as a result of KNOWING that the client has actively said he is done talking to you. But do not put crucial clean-up code in here.
So, when is ejbRemove() called on a session bean?
1) When the container *chooses* to remove a stateLESS bean.
2) When the client calls remove() on a stateFUL bean, and the bean is either passivated or active.
When is ejbRemove() NOT called?
1) When the bean (any type) throws a system exception.
2) When the container crashes
3) When a stateFUL bean times out while passivated.
Now, just one little clarification... a few of you have mentioned ejbLoad(), but remember... there is NO ejbLoad() for session beans
Only entity beans are activated and loaded. StateFUL beans are simply activated, and then the business method (or in this case, the ejbRemove()) is called.
cheers,
Kathy
"One
test to rule them all. One test assigned them. One test to bring them all and in Prometric grind them."