At what point can the container call ejbRemove() on B??
ejbRemove() is called because:
1. The client called remove() on the home or component interface
2. The Container decides to remove the bean after the lifetime of the EJB object has expired.
Note that ejbRemove() is not always called when the bean is destroyed. This would be the case if the bean throws a system exception or if a passivated bean times out. And following a container crash, obviously ...
If it does won't this make the handle stored in B invalid???
When the bean is destroyed, its associated EJB object is also destroyed. Any attempt to access a non-existent EJB object causes java.rmi.NoSuchObjectException to be thrown to a remote client or javax.ejb.NoSuchObjectLocalException to be thrown to a local client.