If a stateless session bean doesn't really care when remove() is called, and as per page 282 of HFE nothing happens to the bean when client calls remove(), how come an exception is thrown if the client tries to use the EJB reference after removing the bean? Isn't removing the bean same as calling remove on the bean?
I have a home ref I call create on home ref I call bus method on component interface then i call remove --> nothing really happens i call bus method on component interface --> does this throw an exception? thx,
When the client calls remove() on a stateless bean (or remove(Handle) on the remote home interface for a stateless ean), the Container doesn't care from the bean object's perspective... in other words, the Container isn't going to kill the bean simply because the client said to remove it. (As opposed to with StateFUL beans where the Container WILL kill the bean as a result of the client saying remove(), since that stateful bean has no meaningful life except for with that one client).
But... the Container DOES acknowledge that the CLIENT is done with that bean. So the Container keeps the bean alive, and the bean never even knows that any of the client's it has serviced are done with it, but the Container still knows which clients have said they were done.
In other words, when the client calls remove() on a stateFUL bean, the client says, "Kill the bean and I am done with it forever." When the client calls remove() on a stateLESS bean, the client says, "I am done with the bean forever". So the Container knows that this client has already said that he is done with the bean, and any attempt by that client to use that bean again means something is wrong with the logic of that client, so the Container complains.
And if the Container had been keeping any resources available for that client, those resources go away.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop