[Solved] org.hibernate.service.UnknownServiceException
org.hibernate.service.UnknownServiceException:
Unknown service requested[org.hibernate.engine.jdbc.connections.spi.ConnectionProvider]
Rootcause: You will get this exception, at the line of opening the session which will be similar like this,
[java]
session = sessionFactory.openSession();
[/java]
If you would have closed the sessionfactory before the above mentioned line executes then you will get the “UnknownServiceException”.
Solution:
Ensure you did not close the sessionfactory before using it in next place and remove or comment if anything exists which resolves this “UnknownServiceException”.
I got the same exception but I closed the sessionfactory, when I removed the below part then “UnknownServiceException” got resolved.
[java]
if (!sessionFactory.isClosed()) {
System.out.println("Closing SessionFactory");
sessionFactory.close();
}
[/java]
Also ensure you have given the above part in the finally section to avoid not termination issue in java.