@ApplicationException is ignored for exceptions in other deployments

Solution Verified - Updated

Environment

  • Red Hat Enterprise Application Platform (EAP)
    • 6.2

Issue

I cannot get the annotation @ApplicationException(rollback = true) to work on a checked exception class, when the exception is deployed in another module than the EAR throwing it.

Resolution

  1. Change the jar from being a deployment to a static module, or
  2. Add an entry to the ejb-jar.xml
  <application-exception>  
    <exception-class>com.example.SomeRollbackException</exception-class>  
    <rollback>true</rollback>  
  </application-exception>

It is generally not advisable to declare cross-deployment classloading dependencies, since it does not add lifecycle dependencies.

Tags

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.