The Answer to Life, the Universe, and Everything

Wednesday, June 20, 2007

Hibernate cfg.xml file

hibernate.cfg.xml file not found issue is the one which troubles us often when we create the web app with hibernate. Here is the workaround code for this issue.

File file=
new File(getServletContext().getRealPath("/WEB-INF/classes/hibernate.cfg.xml"));
SessionFactory sessionFactory =
new Configuration().configure(file).buildSessionFactory();

No comments: