The Container’s responsibilities
If the bean throws an application exception, send it back to the client EXACTLY as it was thrown, and do NOT rollback the transaction.
If the bean throws a CreateException, send that exception to the client. If the bean throws a FinderException, send that exception to the client. If the bean throws an AccountBalanceException, send that exception to the client.
It makes no difference whether the exception is one of the standard EJB exceptions from the java.ejb package, or one that the Bean Provider defined.

If the bean throws a system exception (including EJBException or any runtime exception)
Throw a RemoteException if the client is Remote
Throw an EJBException if the client is local
Log the exception
Rollback the transaction
Discard the bean instance (assume it’s toast)

Brain Power
Think about the client for a moment. If the client gets a RemoteException, does the client know for certain that the business method completed?
Does the client know for certain that the transaction was rolled back?
Is there any way the client might be able to find out?
What if the client is another bean?
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access