Page 1 of 1

About Question enthuware.oce-ejbd.v6.2.501 :

Posted: Thu Jan 03, 2013 2:03 pm
by ETS User
Hello,

Regarding the question of MDB:

...
public void onMessage(Message message) throws java.rmi.RemoteException
...

The answer is "This is an invalid (i.e. non-compliant) EJB 3.x message driven bean."
A 3.x MDB is not allowed to throw RemoteException.


so, what types of exceptions are allowed to be in its throws clause ? :?:

thanks

Re: About Question enthuware.oce-ejbd.v6.2.501 :

Posted: Thu Jan 03, 2013 2:25 pm
by admin
Actually, it cannot throw any checked exception because MessageListener's onMessage does not declare any exception. But it is free to throw any RuntimeException.

However, the specification explicitly mentions that it must not throw the java.rmi.RemoteException and should not, in general, throw RuntimeExceptions.

You might want to take a look at Section 5.4.17 (Dealing with Exceptions) for more details.

HTH,
Paul.

Re: About Question enthuware.oce-ejbd.v6.2.501 :

Posted: Thu Apr 30, 2015 5:34 pm
by himaiMinh
According to 5.4.18 of the spec, MDB can throw RuntimeException that is not an application exception.

So,
MDBs should not in general throw RuntimeException.
I believe it should be application exception because there is no client to catch it.
But I believe it is possible for MDB to throw a system exception and the container will discard the bean.