The config file hibernate.cfg.xml needs to be on the classpath.
This can be accomplished in different ways, depending on your project.
-
For a web-app WAR project (you are running the program in a Servlet container):
placing it inWEB-INF/classeswill work as files inWEB-INF/classesare visible on the classpath when app is running in container. -
For a Maven-style project (not running the program in a Servlet container): placing it in
/src/main/resources/will work -
For otherwise, try in the
src/directory.