Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error running Hibernate Sample Application

 
Rajesh Datla
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am learning Hibernate. while Running Sample application specified in hibernate website http://www.hibernate.org/hib_docs/v3/reference/en/html/tutorial.html
i am getting following error

[java] Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource events/Event.hbm.xml
[java] Exception in thread "main" java.lang.ExceptionInInitializerError
[java] at util.HibernateUtil.<clinit>(Unknown Source)
[java] at events.EventManager.createAndStoreEvent(Unknown Source)
[java] at events.EventManager.main(Unknown Source)
[java] Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource events/Event.hbm.xml

i could not able to find root cause of the problem.

Regards
Rajesh Datla
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Could not parse mapping document from resource events/Event.hbm.xml

Hibernate cannot parse the mapping file Event.hbm.xml. Is it on the classpath? Is it where you specified it should be in your Configuration? Is it valid XML?
 
saranga rao
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

this is the class path problem.i have faced lot of time.
 
sathish kumar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the hbm file under the directory events?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"skumar"

You have been asked before to change your display name to comply with our Naming Policy. We appreciate you posting answers, but please do so before posting again. You can do this here.

Thanks!
 
sanker san
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I faced this problem as I had put a paramater name in the <id > tag.
e.g:-
<id name="custid"> where as my java class didn't have a parameter called custid.
It got resolved when I set the correct parameter in name attribute of <id tag.

Hope it helps
 
akataka
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also you must have below

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

before <hibernate-mapping> ... </..> in your "Event.hbm.xml"
 
Viral Patel
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check that all the property elements are under class element in Event.hbm.xml and class name should be fully qualified name of class(package.classname).

Ex:
<class name="events.Event" table="EVENTS">
<id name="id" column="EVENT_ID">
<generator class="native"/>
</id>
<property name="date" type="timestamp" column="EVENT_DATE"/>
<property name="title"/>
</class>
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
akataka please update your display name ot comply with our naming policy. You can do this here.

Thanks!
[ July 01, 2008: Message edited by: Paul Sturrock ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unique Patel please check your private messages.
 
Alok kumar Ojha
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, i was facing the same issue with tomcat, going though suggestions really helped me.
 
ashwin bala
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, even i am facing the exception ..Please help me as well..I have pasted only my hbm.xml code..If required i ll put the entire code
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic