On page 559 of HFE book, it is mentioned that when a client calls remove() on a bean that's already been removed, clients get RemoteException/EJBException. But, I thought they should get NoSuchObjectException/NoSuchObjectlocalException. However, on page 563 question #2 mentions that the clients will get NoSuchObjectException/NoSuchObjectlocalException. Which one is correct?
NoSuchObjectException/NoSuchObjectlocalException are thrown when the client invokes a method on a bean which has been removed. This is not the same as a client calling remove() on a bean that's already been removed.
This is my understanding. You get NoSuchObjectException thrown if the client tries to invoke a method by using a stub to the EJB Object which is not usable - gone, corrupt, whatever. You get RemoteException thrown if the client, using a stub to a valid EJB Object, invokes remove or any other business method on a bean that's already been removed.