Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes EJB and other Java EE Technologies and the fly likes Impact of system exceptions in EJB 3 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Impact of system exceptions in EJB 3" Watch "Impact of system exceptions in EJB 3" New topic
Author

Impact of system exceptions in EJB 3

Jon Entwistle
Ranch Hand

Joined: Feb 20, 2003
Posts: 118
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!

Regards

Jon



SCJD, SCEA
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Impact of system exceptions in EJB 3
 
Similar Threads
Stateless Session Beans Managing JDBC Transactions
Exceptions from Container to Bean?
Exception qustion in HFEJB
designing with exceptions
Exception Handling in MDB