EJB3.1 System Exceptions vs javax.ejb.EJBException

后端 未结 2 642
终归单人心
终归单人心 2021-02-09 10:18

Just a bit of background on EJB3.1 exceptions before bringing up my question -

Application exceptions comprise of

  • User defined checked or unchecked exc

2条回答
  •  失恋的感觉
    2021-02-09 10:54

    1. 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:

    An application exception shall be thrown when there is a business-logic error, as opposed to a system error.

    There is an important difference: application exceptions do not automatically cause a transaction to rollback. The client has an opportunity to recover after an application exception is thrown.

    Application exceptions are sent to the client without being repackaged as an EJBException. Therefore, you can use them to report validation errors or business logic problems, and they will reach the client.

    1. javax.ejb.EJBException extends RuntimeException 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.

提交回复
热议问题