Stateful session beans, afterCompletion and access rights
posted 10 years ago
I want to post my theory about why the afterCompletion(boolean) has no access right to resource managers and other enterprise beans.
The reason is that when in a transaction, if a rollback occurs, the session bean conversational state may be corrupted. The spec says that a bean developer should use the afterCompletion() method to do any can of re-initialization of conversational state after a rollback.
This is quite easy to understand that if bean state is not correct, is would be very unsafe to allow the bean to communicate with other beans, and (maybe even worse) to allow it to connect to a database and update data with corrupted information.
That's my understanding of why EJB spec disallow these accesses in the afterCompletion() SessionSynchronization of stateful CMT session beans.
I totally disagree with some conclusions I could read in other posts saying that the spec "maybe wrong". Specifications are read, and re-read, and checked and verified, and reviewed, etc... I cannot think they let some so big mistake go live.
And more, I checked the 2.1 spec, it's still the same, so a new revision didn't change anything.
I think my theory is quite logical. What do you think?