It seems that Hibernate 4.3.1 introduced a bug. I create the connection in my application with:
Code:
EntityManagerFactory connection = Persistence.createEntityManagerFactory(...)
but even if the
createEntityManagerFactory method fails with an exception, the service registry remains open. However, as you could see from the above code, I cannot terminate my application because as the method didn't succeed the variable
connection wasn't assigned (it is null), so I cannot call
connection.close() that would destroy the service registry. It seems that this is really a bug, because how will I be able to release resources without resorting to a hack, like using specific Hibernate APIs from a JPA application?
I'm not the only one to have a problem with this issue. Have a look at this discussion:
http://stackoverflow.com/questions/21645516/program-using-hibernate-does-not-terminate
I think that the Hibernate team should have a look at this.
Marcos