I'm using JPA and was trying to create an EntityManager, and was testing some expcetions treatments in a class of mine. However, I'm having a problem, that the exception is not being caught by the catch.
public static boolean openConnection() {
try {
if (emf == null) {
emf = Persistence.createEntityManagerFactory("sysbex"); //linha do erro
em = emf.createEntityManager();
transaction = em.getTransaction();
}
} catch (Throwable e) {
System.out.println("passou aqui"); //essa linha não executa
return false;
}
return true;
}
Can anyone tell me why? ps: I already tried to change the exception type, and also nothing.