File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Could not parse configuration: /hibernate.cfg.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Could not parse configuration: /hibernate.cfg.xml" Watch "Could not parse configuration: /hibernate.cfg.xml" New topic

Could not parse configuration: /hibernate.cfg.xml

Ankit Jindal

Joined: Aug 20, 2010
Posts: 2

Hi Guys,

I am very new to Hibernate and trying to run very simple program of hibernate.
But I am getting following error (Could not parse configuration:/hibernate.cfg.xml
) error. It seems there is some problem with hibernate.cfg.xml.

Initial SessionFactory creation failed kuch .org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.vaannila.util.HibernateUtil.<clinit>(
at com.vaannila.course.Main.saveCourse(
at com.vaannila.course.Main.main(
Caused by: org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(
at org.hibernate.cfg.Configuration.configure(
at org.hibernate.cfg.Configuration.configure(
at com.vaannila.util.HibernateUtil.<clinit>(
... 2 more
Caused by: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect
at org.hibernate.cfg.Configuration.doConfigure(
... 5 more

Here is my hibernate.cfg.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3//EN" " hibernate-configuration-3.0.dtd">
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernateTest</property>
<property name="hibernate.connection.username">root</property>
<property name="show_sql">true</property>
<property name="connection.password">.</property>
<property name="connection.pool_size">10</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="">create</property>
<mapping resource="com/vaannila/course/Course.hbm.xml" />
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 659

Check you DTD in the second line.
there is a space in this - " hibernate-configuration-3.0.dtd".Remove the white space.
Always once you have completed the xml file try opening it in IE. You might catch some errors like this.

If you are not laughing at yourself, then you just didn't get the joke.
Ankit Jindal

Joined: Aug 20, 2010
Posts: 2
Thanks Arun...
It is sorta covered in the JavaRanch Style Guide.
subject: Could not parse configuration: /hibernate.cfg.xml
It's not a secret anymore!