Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Hibernate Configuration File Giving error
PostPosted: Thu Jun 01, 2017 1:14 pm 
Newbie

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 :

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


Now my hibernate.cfg.xml file is :

Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

   <session-factory>
      <property name="hibernate.dialect">
         org.hibernate.dialect.Oracle10gDialect
      </property>
      <property name="hibernate.connection.driver_class">
         oracle.jdbc.driver.OracleDriver
      </property>

      <!-- Assume test is the database name -->
      <property name="hibernate.connection.url">
         jdbc:oracle:thin:@myIp:1521:mySchema
      </property>
      <property name="hibernate.connection.username">
         myuser
      </property>
      <property name="hibernate.connection.password">
         mypass
      </property>
      
      <!-- mapping files -->
      <mapping resource="hbm/myFile.hbm.xml" />

   </session-factory>

</hibernate-configuration>




I keep on getting the error :
Code:
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 :

Code:
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
Code:
<dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-core</artifactId>
         <version>3.6.7.Final</version>
      </dependency>



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

TIA


Top
 Profile  
 
 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: 291
Hi,
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.

Cheers,
Davide


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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.