0
Sponsored Links


Ad by Google
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: org.hibernate.HibernateException: /hibernate.cfg.xml not found
at org.hibernate.internal.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:173)
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1940)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1921)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1901)
at com.hbm.util.HibernateUtility.buildSessionFactory(HibernateUtility.java:13)
at com.hbm.util.HibernateUtility.(HibernateUtility.java:9)
... 2 more


If you found "org.hibernate.HibernateException: /hibernate.cfg.xml not found" error, means hibernate.cfg.xml file is not available inside your project's class path. configure() method of Configuration class try to load hibernate.cfg.xml file from your class path. So put your hibernate.cfg.xml file inside src folder, otherwise you have to provide the location of hibernate.cfg.xml file inside configure(location) method, if it's not placed at your class path.

For example:
Configuration configuration = new Configuration();
configuration.configure("/com/xmls/hibernate.cfg.xml");

If you are using maven build tool for your project then place the hibernate.cfg.xml file inside resources/ folder, then it'll place hibernate.cfg.xml inside your classes folder.

That's it.


Sponsored Links

0 comments:

Post a Comment