[ https://issues.apache.org/jira/browse/OPENEJB-1052?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13596928#comment-13596928 ]
Thomas Herzog commented on OPENEJB-1052: ---------------------------------------- If you add the ApplicationException in your ejb-jar.xml then the Exception is threated as an ApplicationException and will not get wrapped into an EJBException. Also the inheritance will work properly. This has been tested with open-ejb-lite-4.5.1 {code:title="ejb.jar.xml} <?xml version="1.0" encoding="UTF-8"?> <ejb-jar version="3.1" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"> <display-name>CoreServiceImpl</display-name> <assembly-descriptor> <application-exception> <exception-class>com.clevercure.core.base.exception.CoreException</exception-class> <inherited>true</inherited> <rollback>true</rollback> </application-exception> </assembly-descriptor> </ejb-jar> {code} {code:title="root ApplicationException"} @ApplicationException( inherited = true, rollback = true) public class CoreException extends RuntimeException { ... } {code} {code:title="subtype of CoreException"} public class AlreadyAssignedException extends CoreException { ... } {code} > Undeclared @ApplicationException annotated RuntimeExceptions from non-ejb > libraries are always wrapped in EJBExceptions > ----------------------------------------------------------------------------------------------------------------------- > > Key: OPENEJB-1052 > URL: https://issues.apache.org/jira/browse/OPENEJB-1052 > Project: OpenEJB > Issue Type: Bug > Affects Versions: 3.1.1 > Environment: Windows XP, Java 1.6, Maven 2.0.9 > Reporter: Falko Modler > > RuntimeExceptions that are annotated with @javax.ejb.ApplicationException are > only handled as application exceptions when they are declared by the EJB > method (or by an Interceptor AroundInvoke method). > When such an annotated exception is NOT declared by the "throwing method", it > get's wrapped into an EJBException - with all the consequences (EJB will be > discarded, transaction will be rolled back)! > Example: > @javax.ejb.ApplicationException(rollback=false) > public class SomeApplicationException extends RuntimeException { ... > Given an EJB method someEJBMethod that throws SomeApplicationException; this > will prevent SomeApplicationException to be wrapped in an EJBException: > public void someEJBMethod(...) throws SomeApplicationException { ... > But this will not work (SomeApplicationException will be wrapped): > public void someEJBMethod(...) { ... > This seems to happen only if the respective Exceptions is NOT bundled with > the EJB it is thrown by! > e.g.: > A maven project using openejb to test some EJB from the current project which > throws an @ApplicationException annotated RuntimeException that is packed in > an "external" dependency/module. > In contrast: JBOSS 4.2.3 always evaluates @javax.ejb.ApplicationException, > not just for declared exceptions! This is what I expect openejb to do as > well... -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira