Bibhu Jena [https://community.jboss.org/people/bibhu] created the discussion
"Unable to catch RuntimeException in client EJB" To view the discussion, visit: https://community.jboss.org/message/760639#760639 -------------------------------------------------------------- Hi, I want to throw a runtime exception from my dao layer ,and catch it in service layer to parse the exception and show a meaningful message to user. But, when I do this , EJB wraps this exception with RolledBackException and the client EJB is not able to catch it as it expects a SecurityBreakException which extends RuntimeException. I can't throw a checked exception from the class as it implements HibernateListenrs. Adding sample code snippet for more clarity: // after every save/update/delete the follwing class get triggered public class DataChangeListener implements PostDeleteEventListener, PostUpdateEventListener, PostInsertEventListener, Initializable { public void onPostInsert(final PostInsertEvent event) { //check if the user is not allowed to do so ,throw a SecurityBreakException // else do nothing and let the transaction commit. } public void onPostUpdate(PostUpdateEvent event) { //same as onPostInsert } public void onPostDelete(PostDeleteEvent event) { //same as onPostInsert } @Local public interface SaveUserDataService{ public void save(Person person); } //client EJB which expects a SecurityBreakException @Stateful SaveUserDataServiceBean implements SaveUserDataService{ public void save(Person person){ try{ //code to call dao layer to save a person } catch (SecurityBreakException e) { // parse the exception and show a meaningful message to user } } } //The exception class public class SecurityBreakException extends RuntimeException { private static final long serialVersionUID = 1L; String message; public SecurityBreakException(String message) { super(message); this.message = message; } } Please guide. -------------------------------------------------------------- Reply to this message by going to Community [https://community.jboss.org/message/760639#760639] Start a new discussion in EJB3 at Community [https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
_______________________________________________ jboss-user mailing list [email protected] https://lists.jboss.org/mailman/listinfo/jboss-user
