This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes problem parsing configuration / hibernate.cfg.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "problem parsing configuration / hibernate.cfg.xml" Watch "problem parsing configuration / hibernate.cfg.xml" New topic

problem parsing configuration / hibernate.cfg.xml

Divya Shastry

Joined: Dec 05, 2006
Posts: 11
Hi guys ...
I am new to Hibernate and in the learning process, i've got an exception. The stack trace is as follows :

problem parsing configuration/hibernate.cfg.xml
org.hibernate.HibernateException: problem parsing configuration/hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(
at org.hibernate.cfg.Configuration.configure(
at org.hibernate.cfg.Configuration.configure(
at roseindia.tutorial.hibernate.FirstExample.main(
Caused by: org.dom4j.DocumentException: Error on line 7 of document : The content of elements must consist of well-formed character data or markup. Nested exception: The content of elements must consist of well-formed character data or markup.
at org.hibernate.cfg.Configuration.doConfigure(
... 3 more
Exception in thread "main" java.lang.NullPointerException
at roseindia.tutorial.hibernate.FirstExample.main(

The hibernate.cfg.xml is as follows :

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

<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc racle:thin:@HOST:1521:TNS_NAME</property>
<property name="hibernate.connection.username">scott</property>
<property name="hibernate.connection.password">tiger</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="">update</property>
<!-- Mapping files -->
<mapping resource="contact.hbm.xml"/>

Please suggest what is to be done next to overcome the problem

Thanks in advance !
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

The content of elements must consist of well-formed character data or markup

Your config file is not well formed. Looking at the example you have posted it looks OK. Are you sure it is the one you are using? Check all elements are property closed and nested.
[ March 28, 2007: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Divya Shastry

Joined: Dec 05, 2006
Posts: 11
Oh ! I was using another file which had an extra <
Thanks a lot for guiding in that direction !
It is sorta covered in the JavaRanch Style Guide.
subject: problem parsing configuration / hibernate.cfg.xml
It's not a secret anymore!