4
I’m using JPA and was trying to create an Entitymanager, and was testing some expcetions treatments in a class of mine. However, I have a problem, that Exception is not being "caught" by 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 have tried to change the type of exception, and also nothing.
Is there an exception being made? If you put one
System.out.println("Chegou aqui");
after the}
ofif (emf == null)
, this line is executed?– carlosfigueira
@carlosfigueira Yes, a stackTrace is launched on the console. If I put the SOUT after emf == null, it runs, but if put after the
emf = Persistence.createEntityManagerFactory("sysbex");
he does not perform.– Cristiano Bombazar
Can post the stack trace of exception?
– Anthony Accioly
And a crossbow doubt (but it already affected me). You made a clean, build and redeploy total solution?
– Anthony Accioly
Put the full stackTrace
– David Schrammel