• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Impact of system exceptions in EJB 3

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!

Regards

Jon


 
I need a new interior decorator. This tiny ad just painted every room in my house purple.
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic