Deltaspike service layer catching PersistenceException unexpected behavior

95 Views Asked by At

I have a java ee 8 web app using deltaspike using core, data and jsf modules.

I also added cdi bean (RegisterService using @trasactional) which calls a UserRepository

public void createNewUser(User newUser){
      try{
         userRepository.save(newUser) 
      }catch(PersistenceException ex){
          throw new RegisterException("Error", ex); //it never falls at this point
      }
}

When service layer calls repository I’m catching a PersistenceException and rethrowing a service layer exception but the repository never throws PersistenceException even if the primary ID is duplicated (I just can see the stacktrace in console output), of course I’m running into a contraint exception to try to execute the expected flow

I’m using a deltaspike exception handler but I have not added a @handler for PersistenceException

Does somebody knows what could be happening here?

this is a reproducible example: https://github.com/gdiazs/javaee8-fullstack

Since there is no tables in DB it will throw an PersitenceException.

I ran this example in 2 laptops.

Mine: OSx 10.14.6
JDK: Open JDK Zulu 1.8
eclipse and also maven terminal execution

Work: OSx 10.14.6 (it works as I expect good here)
JDK: Oracle 1.8
Intellij and also maven terminal execution

So now I`m really confused, no idea why is working just in one.

0

There are 0 best solutions below