Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Application Exceptions

 
nitin pai
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • 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?
 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • 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)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic