Wednesday, 19 August 2015

Exception in thread "main" java.lang.ExceptionInInitializerError at Test.Test.main(Test.java:20) Caused by: org.hibernate.HibernateException: /hibernate.cfg.xml not found

such type of exception may occur in hibernate when the configuration file - hibernate.cfg.xml can not be located by the hibernate system while developing project in Eclipse IDE. it is because if you have not given the path for the hibernate.cfg.xml file properly ..
if in your eclipse project if you are keeping your files in different packages then make sure you gave the path of the packages..
to solve the above problem you need to follow the below steps
Procedure number 1:
1)you need the give the path of the package in your mapping file(say here employee.hbm.xml)  for the name attribute of  <class name="<here>"  >  tag ..

2)and also you need to provide the full package path in the  <mapping resource="<here> "> tag of the hibernate.cfg.xml file

again while creating the Configuration  Object also you need to provide the full package name in the configure(< here> ) method

so by above process you make your hibernate system know from where to locate the hibernate.cfg.xml file

Procedure number 2

instead of procedure number 1 you can simply place you configuration file and mapping file inside the classes folder of WEB-INF 
simply copy and paste the hibernate.cfg.xml and hbm.xml(here employee.hbm.xml inside the classes folder of WEB-INF folder


Tuesday, 18 August 2015

Exception in thread "main" org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available

Such exception occurs usually in cases like if  we missed the configure() method while creating Configuration Object for Hibernate system followed by  the SessionFactory object.
one of the simplest way to remove such exception is simply by adding configure() method

here is an example of such case

   the easy to solve this problem is simply replace this code by
Configuration config=new Configuratio().configure();
or
Configuration config=new Configuration();
config.configure();

hope it solved your problem


thanks and regards 
ErrorsException Team