What's the main difference between throwing an javax.ejb.EJBException and throwing an java.rmi.RemoteException from within a EJB? When should each be thrown?

Dan Christopherson

The main difference is that throwing remote exception from within the bean is deprecated: your bean methods (including ejbLoad, ejbStore and their ilk) should throw EJBException. Other things to note from the spec are that the current transaction will be rolled back (it wouldn't be if you threw an application exception), and the client will see it as a RemoteException, even though you threw an EJBException.