Yea, ejbRemove() will be called by the container on bean instance when the client invoke remove() method in the ejbObject of the stateful session bean. This will be called only once in the life cycle of a stateful session bean.
The difference between the two calls is not about time. ejbPassivate() is called by the container only when it is running short on resources(memory). If the server is not low on resources it will not bother to passivate a bean even though the bean has been around for a while. As for the ejbRemove() method, it gets called by the container when a bean has timed out. Timeout is not about how long the bean has been in the 'method ready' state, it is about how long the bean has been left idle. A bean could time out when the bean is in the 'method ready' state or when it has been passivated. If it is in the passivated state, then it gets removed without getting re activated.
Hope this helps.. You may want to refer to pg184 - 185 of HFEJB for more info. Cheers ! [ April 27, 2005: Message edited by: linoops ]
Though both ejbPassivate and ejbRemove are releasing resources they are not same by any means. When passivating the EJB container store/ persists the state of EJB and release resources. But removing is just like assign null into the reference. Meaning of removing passive EJB is removing the stored state of the EJB from the storage. Hope this helps