If...
- Client invokes remove(Object primaryKey) on a session bean - session beans do not have primary keys.
OR
- Session bean instance is participating in a transaction and the client invokes the
remove method on the session object�s home or component interface object.
Then...
RemoveException will be thrown
These two scenarios are considered separately in pages 558 and 559.
"Client calls remove() on a stateful bean that is still in an open tx"
"Client call the home remove method on the home interface of a session bean"
In both scenarios the book says you get a RemoveException as Keerthi points out. That's fine.
The other scenario, the one Giju is talking about, says "Client calls remove() on a bean that's already been removed"
I agre with Giju in that in this case
you should get a NoSuchObjectException, specially when the book says "remove() is just another method in the bean's interface ... you'll get the same exception you'd see if you called any other business method on a removed bean". So we're not talking about removes in the home interface and calling remove within an open transaction is also considered separately. The only choice here has to be NoSuchObjectException ...
So can we say the book is wrong??