I call account
EJB method in JSF bean like that :
try{
account.someFunction(...);
}catch(SimRuntimeException e){
logger.log(Level.FATAL, "SimRuntimeException catched !");
}catch(SimNotRuntimeException e){
logger.log(Level.FATAL, "SimNotRuntimeException catched !");
}catch(Exception e){
logger.log(Level.FATAL, "Exception catched !");
}
My Exceptions :
public class SimRuntimeException extends RuntimeException {
public SimRuntimeException() {
super();
}
}
@ApplicationException(rollback=true)
public class SimNotRuntimeException extends Exception {
public SimNotRuntimeException() {
super();
}
}
- when
account.someFunction(...);
throwsSimRuntimeException
I fall intoException
block because mySimRuntimeException
is wrapped intoEJBException
probably by EJB container. - when
account.someFunction(...);
throwsSimNotRuntimeException
I fall as expected intoSimNotRuntimeException
So, what is concretely the difference between Exception
with @ApplicationException(rollback=true)
and RuntimeException
please ?