i am not sure if i will get an exception for calling a remove on a stateless session bean. all i could say is... i have called it in my session beans trial.. nothing will happen. the container will not actually bother abt the call it will neither give any exception nor call ejbRemove(). i dont have the HFEJB with me now but it is mentioned in that book in the session beans chapter. can someone clarify about the exception... anyways how do i force a remove() call to a session bean in the first place?
You will not get an exception for calling remove() on the EJBObject of a stateless bean. (spec p88) You are telling the container you are done with it but it is up to the container when it wants to destroy the bean (ejbRemove()). Instead, calling remove() will destroy the reference to the component interface. Any client that tries to use that same reference will get a NoSuchObject(Local)Exception.
I think when remove is called on a stateless session bean, the bean goes back to the pool created by the container. Now its upto the container to decide. if the container thinks that it is running low on resources, it might decide to reduce the pool size by removing the beans from the pool during which it will call ejbRemove() method for the corresponding bean instance.