• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Savannah David
Greenhorn
Posts: 16
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>


 
Manuel Petermann
Ranch Hand
Posts: 177
Hibernate Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The exception is actually telling what is wrong.
"mapping-resource" should be "mapping resource"
 
Savannah David
Greenhorn
Posts: 16
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot... now its working
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic