Hi,
Stephan Gruschke wrote:
> just an suggestion for the bean exception handling inside jboss:
>
> Maybe we should create a new exception type 'BeanException' which is
> thrown from the modules to indicate that the executing bean has thrown an
> exception.
Sounds good. It would probably also make it easier to distinguish
between exceptions from beans and exceptions in the container code.
> We could provide some more information in the BeanException:
> - name of bean
> - original exception (including stacktrace...)
> - was exception declared in bean interface ((un)expected exception?)
> - etc....
>
> The exception type would be more informative than
> 'InvocationTargetException' because this exception could have been
> originated from any internal module of jboss.
Yes. At least the InvocationTargetException should be unwrapped.
> For design purpose we could even extend BeanException to
> SessionBeanException, EntityBeanException, etc....
I think that exceptions from different bean types are sufficiently
equal that we do not need to subclass this way.
But it might be an idea to subclass to BeanApplicationException (for
application exceptions thrown from the bean) and BeanSystemException
(for encapsulating all other Throwable thrown from the bean).
> The proxy could unwrap the original exception from the BeanException
> object and throw it towards the client.
Careful here: On the wire we should send the exception that the EJB
specification says the client should have. Otherwise we run into
problems with interoperability with other systems. So having the
client stub doing the unwrap is not an option. Instead the unwrap
should probably happen at the server just before sending the exception
back to the client.
I have written a test bean that does some tests on exception handling.
You can find it at http://www.sparre.dk/unpublished/jbosstest.tar.gz.
It is not yet quite finished, but works well enough to demonstrate my
problem.
While writing this I noticed that TxInterceptor adds an extra layer
of encapsulation to a thrown EJBException (EJBException in a
ServerException in a RemoteException).
Best Regards,
Ole Husgaard.