aspose file tools*
The moose likes Object Relational Mapping and the fly likes org.hibernate.HibernateException: Could not parse 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 "org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml" Watch "org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml" New topic
Author

org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml

Savannah David
Greenhorn

Joined: Jun 07, 2012
Posts: 15

hi all,

I am new to hibernate trying to execute my first hibernate code. But I am getting an error. Please help me out..
error is:

Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1376)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1296)
at Test.main(Test.java:16)
Caused by: org.dom4j.DocumentException: Error on line 12 of document : Element type "mapping-resource" must be followed by either attribute specifications, ">" or "/>". Nested exception: Element type "mapping-resource" must be followed by either attribute specifications, ">" or "/>".
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1366)
... 3 more

Here is my hibernate.cfg.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/test</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<mapping-resource="./com/entity/Message.hbm.xml" />
</session-factory>
</hibernate-configuration>



You're never a loser until you quit trying.
Manuel Petermann
Ranch Hand

Joined: Jul 19, 2011
Posts: 175

The exception is actually telling what is wrong.
"mapping-resource" should be "mapping resource"


Please correct my English.
Savannah David
Greenhorn

Joined: Jun 07, 2012
Posts: 15

thanks a lot... now its working
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
 
Similar Threads
newcomer to the hibernate 4.1.2, but the first program doesn't work
hibernate hello world
Hibernate cfg xml and Eclipse problem
Could not parse configuration: /hibernate.cfg.xml
Could not parse configuration: /hibernate.cfg.xml