• 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Application Exceptions

Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The core EJB specs, chapter "Exception Handling", page 356, says

An application exception may be a subclass (direct or indirect) of java.lang.Exception (i.e., a
�checked exception�), or an application exception class may be defined as a subclass of the
java.lang.RuntimeException (an �unchecked exception�).

Further it says,

An application exception thrown by an enterprise bean instance should be reported to the client
precisely (i.e., the client gets the same exception)[74].

But on page 358 it says

If the bean method performs an operation that results in a checked exception[76] that the bean
method cannot recover, the bean method should throw the javax.ejb.EJBException
that wraps the original exception.

I have 2 question in this:
#1. If I make a custom application exception eg:MyAppException then will the client recieve MyAppException or EJBException?
#2. I want to know what is meant by "that the bean cannot recover". If the bean could recover why would throw it in the first place as an application exception?
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. You receive your application exception
2. For example, if you make a sql query and you get an SQLException, you should throw new EJBException(SQLException)
    Bookmark Topic Watch Topic
  • New Topic