• Post Reply Bookmark Topic Watch Topic
  • New Topic

Impact of system exceptions in EJB 3  RSS feed

Jon Entwistle
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I was looking throough the chapter on CMT in EJB 3 in action (P. 196), and was suprised to see this advice:

"in such cases [when a system exception is thrown] the container will assume that the bean is inconsistent and will destroy the instance. Because unnecessarily destroying bean instances is costly, you should never deliberately use system exceptions."

Is this correct? Surely this only applies to SFSB instances?

Also, based on my experience I would argue that SLSB methods should only throw checked exceptions if clients can reasonably be expected to take some remedial action. Otherwise (the most common case) checked exceptions should be wrapped in a runtime exception (which in turn would be wrapped in an EJBException) and interpreted in an error handler in the client to show an appropriate error message based on the exception type/message.

I want to make sure that the error handling strategies that I apply follow best practices, but this comment has left me wondering. Any comments/opinions appreciated!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!