These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]

Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Configuration File Giving error
PostPosted: Thu Jun 01, 2017 1:14 pm 

Joined: Thu Jun 01, 2017 11:41 am
Posts: 1
This has been driving me crazy since morning.
Now in a maven based project i place my hibernate.cfg.xml file in src/main/resource folder
and i am using following code to set up the connection :

sessionFactory = new Configuration().configure("hibernate.cfg.xml").buildSessionFactory();

Now my hibernate.cfg.xml file is :

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"


      <property name="hibernate.dialect">
      <property name="hibernate.connection.driver_class">

      <!-- Assume test is the database name -->
      <property name="hibernate.connection.url">
      <property name="hibernate.connection.username">
      <property name="hibernate.connection.password">
      <!-- mapping files -->
      <mapping resource="hbm/myFile.hbm.xml" />



I keep on getting the error :
org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2246)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:2158)
   at com.demo.getSessionFactory(HibernateUtil.java:27)
   at com.demo.openSession(HibernateUtil.java:36)
Caused by: org.dom4j.DocumentException: null Nested exception: null
   at org.dom4j.io.SAXReader.read(SAXReader.java:484)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2238)
   ... 179 more

If i move the file to some other folder i get :

org.hibernate.HibernateException: hibernate.cfg.xml not found
   at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:170)
   at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:2176)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:2157)
   at com.demo.getSessionFactory(HibernateUtil.java:27)
   at com.demo.openSession(HibernateUtil.java:36)

which means it is in right folder for use.

What am i doing wrong, Is there some jar missing?. I am using dependency

Maybe there is something really stupid that I am doing but i am unable to figure that out.


 Post subject: Re: Hibernate Configuration File Giving error
PostPosted: Mon Jun 05, 2017 6:54 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
the hibernate ORM version you are using i very old and not supported anymore,
you should try the latest stable version 5.2.4.Final.

Also, this group is about Hibernate OGM and it seems you have problem with Hibernate ORM.


Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.