title: Java EE: @ApplicationException thrown, still rolls back transactions
body: <p>I need some direction how to best use Exceptions in a Java EE environment, serving clients via JAX-RS.</p>
  
  <p>At the moment, I have a number of exceptions, all extending <code>RuntimeException</code>, and annotated with <code>@ApplicationException(rollback=false)</code>. In order to transport them to the clients, they carry a JAXB-annotated entity; and an <code>ExceptionMapper</code> is ready to convert them to proper, meaningful HTTP Responses (HTTP Status codes included).</p>
  
  <p>I have nothing specified regarding transactional behaviour, so I guess it defaults to CMT.</p>
  
  <p>Great stuff so far: when the server decides, it cannot fulfill a request, because input data is not valid/sufficient/whatever, it throws one of my <code>BadRequestException</code>, which makes it to the JAX-RS resource, where it gets mapped to a HTTP Response. Client is informed about what went wrong.</p>
  
  <p><strong>The issue</strong> I have is that I always get a <code>javax.ejb.TransactionRolledbackLocalException</code>, caused by <code>BadRequestException</code>! I don't want the transaction to be rolled back! The @ApplicationException seems to be ignored...</p>
  
  <p>Should I not extend from <code>RuntimeException</code> but rather use checked exceptions? I though @ApplicationException was supposed to be the right way...</p>
  
  <p>For background information: all of my Exceptions leave the container/beans in a working state. No need for the bean instance to be destroyed or stuff like that.</p>