aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Impact of system exceptions in EJB 3
 
Similar Threads
designing with exceptions
Exception Handling in MDB
Stateless Session Beans Managing JDBC Transactions
Exception qustion in HFEJB
Exceptions from Container to Bean?