title: Throwing an application exception causes TransactionalException
body: <p>I am implementing an JEE7 web application. During my work i have found a problem with handling  my custom exceptions.</p>
  
  <p>I edited my account's property to have a non-unique login field. Then i invoked the <code>AccountEditBean#editAccount()</code> to run the editing process. When the process comes to <code>AccountFacade#edit()</code> i can see (in debug) that <code>PersistenceException</code> is caught and my custom <code>NonUniqueException</code> is thrown. The problem is, the exception is not propagated out of the facade class and it is not handled in <code>AccountEditBean</code>. Instead of that <code>TransactionalException</code> occurs right after <code>throw</code>:</p>
  
  <pre><code>WARNING:   EJB5184:A system exception occurred during an invocation on
  EJB ADMEndpoint, method: public void
  pl.rozart.greatidea.adm.endpoints.ADMEndpoint.editAccount(pl.rozart.greatidea.entities.Account)
  throws pl.rozart.greatidea.exceptions.BaseApplicationException
  WARNING:   javax.transaction.TransactionalException: Managed bean with
  Transactional annotation and TxType of REQUIRES_NEW encountered
  exception during commit javax.transaction.RollbackException:
  Transaction marked for rollback.
  </code></pre>
  
  <p>Additional information:
  <code>NonUniqueException</code> extends <code>BaseApplicationException</code> , which is marked as <code>@ApplicationException(rollback=true)</code>.</p>
  
  <p>Here's the code for the edit process:</p>
  
  <p>AccountEditBean:</p>
  
  <pre><code>@Named(value = "accountEditBean")
  @ViewScoped
  public class AccountEditBean extends UtilityBean implements Serializable {
  
      @Inject
      ADMEndpointLocal admEndpoint;
  
      private Account account;
  
      public void editAccount() {
          try {
              admEndpoint.editAccount(this.account);
              Messages.addInfo(ACCOUNT_DETAILS_FORM, KEY_CHANGES_SUCCESS);
          } catch (NonUniqueException e) {
              Messages.addError(ACCOUNT_DETAILS_FORM, e.getMessage());
          } catch (BaseApplicationException e) {
              Messages.addFatal(ACCOUNT_DETAILS_FORM, e.getMessage());
          }
      }
  
  }
  </code></pre>
  
  <p>ADMEndpoint:</p>
  
  <pre><code>@Stateful
  @Transactional(Transactional.TxType.REQUIRES_NEW)
  @TransactionTracker
  public class ADMEndpoint extends LoggingStateBean implements ADMEndpointLocal, SessionSynchronization {
  
      @EJB(name = "ADMAccountFacade")
      private AccountFacadeLocal accountFacade;
  
      private Account account;
  
      @Override
      public void editAccount(Account account) throws BaseApplicationException {
          this.account.setLogin(account.getLogin());
          this.account.setEmail(account.getEmail());
          accountFacade.edit(this.account);
      }
  
  }
  </code></pre>
  
  <p>ADMAccountFacade:</p>
  
  <pre><code>@Stateless(name = "ADMAccountFacade")
  @Transactional(Transactional.TxType.MANDATORY)
  @TransactionTracker
  public class AccountFacade extends AbstractFacade&lt;Account&gt; implements AccountFacadeLocal {
  
      @PersistenceContext(unitName = "myPU")
      private EntityManager em;
  
      @Override
      public void edit(Account account) throws BaseApplicationException {
          try {
              em.merge(account);
              em.flush();
          } catch (PersistenceException e){
              if(e.getMessage().contains(Account.CONSTRAINT_ACCOUNT_LOGIN_UNIQUE)){
                  throw new NonUniqueException(NonUniqueException.MSG_NON_UNIQUE_ACCOUNT_LOGIN, e);
              }else{
                  throw new BaseDatabaseException(BaseDatabaseException.MSG_GENERAL_DATABASE_ERROR, e);
              }
          }
      }
  }
  </code></pre>
  
  <p>Do you know what could be the cause of the problem? It occurs in every of my facades, with all the custom exceptions.</p>