A quote from the EJB specification:
If the bean method encounters a system exception or error, it should simply propagate the error from the bean method to the container (i.e., the bean method does not have to catch the exception).
But I don't understand it. Does it mean that I shouldn't catch all types of exceptions (i.e. try to catch Exception
class) and rethrow it as my application exception?
An example for more clarity:
public void beanMethod throws MyApplicationException {
try {
// do something
} catch (Exception e) {
throw new MyApplicationException(e); // Should I do it like this?
}
}
Or is this not for EJB developers, but only for EJB reference-implementation developers (container developers): In the latter case, as a consequence, the container must not propagate system exceptions to my business method, and my catch(Exception e)
block never catches any system exception?