aspose file tools*
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
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "problem parsing configuration / hibernate.cfg.xml" Watch "problem parsing configuration / hibernate.cfg.xml" New topic
Author

problem parsing configuration / hibernate.cfg.xml

Divya Shastry
Greenhorn

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(Configuration.java:1291)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1230)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1216)
at roseindia.tutorial.hibernate.FirstExample.main(FirstExample.java:22)
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.dom4j.io.SAXReader.read(SAXReader.java:350)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1286)
... 3 more
Exception in thread "main" java.lang.NullPointerException
at roseindia.tutorial.hibernate.FirstExample.main(FirstExample.java:38)

The hibernate.cfg.xml is as follows :

<?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.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="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping resource="contact.hbm.xml"/>
</session-factory>
</hibernate-configuration>

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

Thanks in advance !
Paul Sturrock
Bartender

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
Greenhorn

Joined: Dec 05, 2006
Posts: 11
Oh ! I was using another file which had an extra <
Thanks a lot for guiding in that direction !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem parsing configuration / hibernate.cfg.xml