我像这样在JSF bean中调用account EJB方法:

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 !");
}

我的异常(exception):
public class SimRuntimeException extends RuntimeException {

   public SimRuntimeException() {
      super();
   }

}



@ApplicationException(rollback=true)
public class SimNotRuntimeException extends Exception {

   public SimNotRuntimeException() {
      super();
   }


}
  • account.someFunction(...);抛出SimRuntimeException我摔倒时
    放入Exception块,因为我的SimRuntimeException已包装
    可能是通过EJB容器转换为EJBException的。
  • account.someFunction(...);抛出SimNotRuntimeException时,我按预期坠落
    变成SimNotRuntimeException

  • 那么,Exception@ApplicationException(rollback=true)RuntimeException之间的具体区别是什么?

    最佳答案

    Pal's blog状态:

    09-03 17:39