users@ejb-spec.java.net

[ejb-spec users] [EJB 3.1] Subclass of a checked @ApplicationException with inherited=false

From: Rafael Vanderlei <rafaelvanderlei_at_gmail.com>
Date: Wed, 12 Feb 2014 18:38:52 -0200

Hi everyone.

I'm a little confused about what EJB 3.1 specification says regarding to
ApplicationException in the case taht we have a subclass of a checked
@ApplicationException with inherited=false.

Section 14.2.1 of EJB 3.1 spec states very clearly that subclasses of an
unchecked exception marked with @ApplicationException(
inherited=false) are not considered to be Application Exception and so will
be wrapped by EJBException, mark transaction to rollback, force the EJB
container to log the exception so the system administrator can be alerted,
and so on..

What happens is that I'm running an application in JBoss EAP 6.1 (that
claims to be fully compliant to ejb spec) which is presenting some behavior
that, in my opinion, is not in compliance to the spec (unless I
misunderstood container responsabilities described in table 15 - section
14.3.1):

I have the following hierarchy of exceptions:

@ApplicationException(
rollback=true,inherited=false)
public class ExceptionA extends Exception{...}
public class ExceptionB extends ExceptionA{...}

When some EJB method throws ExceptionB, JBoss doesn't rollback the
transaction, the client receives the same ExceptionB (both expected
behaviors so far), but it is logging the exception as an ERROR (this is
what I was not expecting as ExceptionB should be treated like an
ApplicationExceptions).

My question is: according to the spec, ExceptionB should be considered an
ApplicationException or not? If yes, the way JBoss is behaving (logging the
exception as ERROR) should still considered to be compliant to the spec?

I'm asking this here instead of in JBoss forums because I'd like to know
the expected behavior according to the specification in this situation and
a opinion from the spec point of view about if the container is compliant
or not to the spec.

Thanks.