问题描述
应用程序例外包含
-
具有
@ApplicationException注释的用户定义的已检查或未检查的异常 -
所有检查的异常
java.lang.Exception&它是子类异常
除了java.rmi.RemoteException&它是子类异常
系统异常包括
-
java.rmi.RemoteException,它是子类异常
-
所有未选中的异常
java.lang.RuntimeException,它是子类异常
java.lang.Error,它是子类异常
以下是我在此中阅读的声明
我的问题 -
- 上面提到的异常应该由EJB直接抛出给客户端?
- 如果系统异常在抛出客户端之前被包含在javax.ejb.EJBException中,那么是java x.ejb.EJBException被视为系统异常?
- 是的,或多或少是他们的工作方式。有关EJB行为的更多详细信息,请查看以下博文:
同样从这个:
-
javax.ejb.EJBException
extendsRuntimeException
所以是的,这是一个系统异常
与此相关联的常见方案:如果您没有收到 RuntimeException
在您的应用程序代码中将会回滚。这是非常有用的默认行为。
Just a bit of background on EJB3.1 exceptions before bringing up my question -
Application exceptions comprise of
User defined checked or unchecked exceptions which have@ApplicationException annotation
All checked exceptions
java.lang.Exception & it's subclass exceptions
except java.rmi.RemoteException & it's subclass exceptions
System exceptions comprise of
java.rmi.RemoteException and it's subclass exceptions
All unchecked exceptions
java.lang.RuntimeException and it's subclass exceptions
java.lang.Error and it's subclass exceptions
Below is a statement I have read in this book
My questions -
- Are all application exceptions described above supposed to be thrown directly by EJB to client?
- If System Exceptions are wrapped inside javax.ejb.EJBException before throwing to the client, then is javax.ejb.EJBException considered as System Exception?
- Yes, more or less that's how they work. For further details on EJB's behaviors check out the following blog post: Link
Also from this question:
javax.ejb.EJBException
extendsRuntimeException
so yes, it is a System Exception.
Common scenario associated with this: if you've got an uncaught RuntimeException
in your application code it will roll-back. It's pretty useful default behavior.
这篇关于EJB3.1系统异常vs javax.ejb.EJBException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!