I'm experiencing a strange issue. I am calling a Spring-managed bean from a JSF managed-bean and for some reason, the JSF bean won't catch a checked exception. Here's the method that throws the exception:
The above "saveUser" method is in a UserManager class, which is wrapped in a TransactionProxyFactoryBean.Code:public void saveUser(User user) throws UserExistsException { try { dao.saveUser(user); } catch (DataIntegrityViolationException e) { throw new UserExistsException("User '" + user.getUsername() + "' already exists!"); } }
In my JSF Bean I have:
After some checking, it seems that the UserManager is unable to catch the DataIntegrityViolationException. I tried using + and - in my transaction attributes, but had no luck.Code:try { userManager.saveUser(user); } catch (UserExistsException ue) { log.warn(ue.getMessage()); // for some reason - MyFaces doesn't seem to catch this exception } catch (DataIntegrityViolationException e) { log.warn(e.getMessage()); addError("errors.existing.user", new Object[] { user.getUsername(), user.getEmail() }); return "editProfile"; }
Seems like I'm just not seeing something, as I'm guessing that catching exceptions should be possible in TransactionProxy-wrapped beans.


Reply With Quote