Application vs System Exception

Discussions

EJB design: Application vs System Exception

  1. Application vs System Exception (1 messages)

    Quote from EJB2.0 specs:

    "An application exception is an exception defined in the throws clause of a method of the enterprise Bean's home
    and component interfaces, other than the java.rmi.RemoteException.".
    It further says that an application exception is supposed to extend from Exception and not from RuntimeException
    or RemoteException (which are reserved for system exceptions).

    However even if an exception extends from RemoteException and is still specified in the throws clause of a
    business method, it is treated as an application exception and does not cause a rollback.
    But if it is not specified in the throws clause, it is supposed to cause a rollback.

    Does the throws clause decide if an exception is application or system or is it the exception hierarchy?
  2. Application vs System Exception[ Go to top ]

    All the exception declared in the throws clause of a method are application-exceptions with the exception of RemoteException. The SystemException is thrown by the EJB container only and it rolls back the transaction. The SystemExcepion can be checked as well as unchecked. If the system experiences unchecked SystemException, it throws the RemoteException. If the SystemException intercepted by the EJB container is checked exception, then the bean code should catch it and throw EJBException which is a RuntimeException and it need not be decalred in the throws clause of the interface.