1 Reply Latest reply on Jan 11, 2008 10:35 AM by dimitris

    @ApplicationException(rollback=false) does roll back @PreUpd

    skeyewalk

      I have encountered a very unfortunate and strange difference in the way JBoss application server 4.2.2 treats exceptions raised from inside EJB callback methods marked with @PrePersist and @PreUpdate.

      My exception is a RuntimeException, and is marked for rollback=false. I use it to report back validation errors. The validation is triggered in the @PrePersist and @PreUpdate callback methods. However, while this behaves very nicely for the persist method, the update does not appear to take the @ApplicationException annotation into account. So the transaction is rolled back and my exception is wrapped inside a javax.persistence.PersistenceException and then inside a javax.transaction.RollbackException, blowing up my whole concept.

      I have also tried configuring the ApplicationException in the ejb-jar.xml, but the result was identical.

      Here's the exception class:

      @ApplicationException(rollback=false)
      public class ValidationExceptionRuntimeWrapper extends RuntimeException
      {
       private static final long serialVersionUID = 1L;
      
       private ValidationException validationException;
      
      
       public ValidationExceptionRuntimeWrapper(ValidationException validationException)
       {
       this.validationException = validationException;
       }
      
       public ValidationException getValidationException()
       {
       return validationException;
       }
      
       public void setValidationException(ValidationException validationException)
       {
       this.validationException = validationException;
       }
      
      }
      


      Has anyone seen this before or knows how to explain this?
      I would be so grateful for any help!!