Win a copy of Terraform in Action this week in the Cloud forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

A question about application exception thrown by a business method

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,
Another question about why an application exception is thrown by a business method won't make container kill the bean, but if the exception is thrown by ejbXX() methods, container will do it?
Thanks again!
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The application exception is regarded as expected and have to be handled by the invoker. As the invoker expect the exception the exception is supposed to be handled more gracefully than by just kill the bean.
The system exception is not expected and seen as something that there is nothing to do anything about. In that case the container tries to limit the damage as much as possible by killing the bean.
/Magnus
 
Kuo-Feng Sun
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Magnus,
Thanks for your instant reply.
But I still have something that I cannot understand. Is an application exception a kind of runtime exceptions or compiled exceptions? Besides, I don't know if system exception are runtime ones or the other ones?
Thanks again.
Kuo-Feng
 
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Kuo-Feng Sun,
Application exceptions are always checked exceptions. These are exceptions that the client expects to happen and can deal with. Checked exceptions must be either caught or thrown and the compiler will always ensure this. Some examples are CreateException, FinderException and RemoveException. A bean provider can also define his own application exceptions by extending Exception or one of the checked exceptions except for RemoteException.
System exceptions are always runtime exceptions, except for RemoteException which is a checked exception. System exceptions indicate that something unrecoverable happened on the server. The compiler will not check for handling of these exceptions. If the container recieves a runtime exception from a bean it will rethrow it to a remote client as a RemoteException or to a local client as an EJBException. The container will also rollback the transaction, log the exception and kill the bean. Some examples of runtime exceptions related to EJBs are NoSuchObjectException, TransactionRequiredException and IllegalStateException.
Refer to Head First EJB for a more in-depth coverage of exceptions.
Hope this helps.
[ January 29, 2004: Message edited by: Keith Rosenfield ]
[ January 29, 2004: Message edited by: Keith Rosenfield ]
 
Kuo-Feng Sun
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Keith Rosenfield,
Thanks for your complete explanation about these concepts.
Sorry that I just read the session bean part of the book. Your reply really helps me a lot!
 
reply
    Bookmark Topic Watch Topic
  • New Topic