Hi All, Relative newbie to Hibernate. I'm using Eclipse 3 and have developed a standalone Java console application. It contains hibernate.cfg.xml in the project directory root. Everything works perfectly fine from within Eclipse.
However, when I export to a JAR and try to run it I get the following exception and log4j trace. I'm stumped. hibernate.cfg.xml is in the root of the jar as others have advised.
I've tried both of these to no avail.
Code:
// The cfg.configure(...) is MySessionFactory.java:48 in the following trace.
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");
// or alternatively with the slash
cfg.configure("/hibernate.cfg.xml");
I'm sure this a FAQ, but I'll certainly don't see the answer!
Any help is greatly appreciated.
Hibernate version: 2.1.4
Full stack trace of any exception that occurs:
net.sf.hibernate.HibernateException: /hibernate.cfg.xml not found
at net.sf.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:849)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:873)
at com.wrg.util.hibernate.MySessionFactory.currentSession(MySessionFactory.java:48)
Debug level Hibernate log excerpt:
19:37:48,591 INFO Environment:462 - Hibernate 2.1.4
19:37:48,591 INFO Environment:491 - hibernate.properties not found
19:37:48,601 INFO Environment:522 - using CGLIB reflection optimizer
19:37:48,601 INFO Configuration:872 - configuring from resource: /hibernate.cfg.xml
19:37:48,601 INFO Configuration:844 - Configuration resource: /hibernate.cfg.xml
19:37:48,601 WARN Configuration:848 - /hibernate.cfg.xml not found