0
votes

I use JSF 2 and EJB 3.

I think my use case is pretty simple :

A JSF backing bean is calling a method on an injected ejb. The ejb can throw a custom exception. When the exception occurs, I want the transaction to be rollbacked AND the exception to be catched in my JSF bean (so it can deal with the user).

So I annotated my custom exception with @ApplicationException(rollback=true) and threw it from my ejb method.

But my problem is that my custom exception never makes it to the jsf bean. Instead, it comes wrapped in a EJBTransactionRolledBackException.

If I annotate my exception with @ApplicationException(rollback=false), then the transaction is not rolled back and the exception is catched by the JSF bean.

Is there a mean to rollback a transaction AND to throw an Application exception catchable ?

Could it be glassfish specific ? (i'm using glassfish 3.1.1).

1
Based on what you've stated, it looks like a product defect. I would suggest submitting a bug report. - Brett Kail

1 Answers

0
votes

Are you catching or throwing the exception in your managed bean? If the custom exception inherits from "Exception" then try the throws clause instead of using try/catch (assuming that's what you're doing).

If your custom exception inherits from "RuntimeException" then you shouldn't have to use either the try/catch or the "throws" clause.

This is what I am doing and it works. Other than that I don't know.