File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Error running Hibernate Sample Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Error running Hibernate Sample Application" Watch "Error running Hibernate Sample Application" New topic
Author

Error running Hibernate Sample Application

Rajesh Datla
Greenhorn

Joined: Mar 28, 2007
Posts: 6
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

Joined: Apr 14, 2004
Posts: 10336


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?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
saranga rao
Ranch Hand

Joined: Apr 24, 2007
Posts: 49
Hi,

this is the class path problem.i have faced lot of time.
sathish kumar
Ranch Hand

Joined: Feb 14, 2007
Posts: 47
Is the hbm file under the directory events?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

"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

Joined: Dec 17, 2004
Posts: 56
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

Joined: Jun 11, 2008
Posts: 3
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

Joined: Jul 01, 2008
Posts: 1
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

Joined: Apr 14, 2004
Posts: 10336

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

Joined: Apr 14, 2004
Posts: 10336

Unique Patel please check your private messages.
Alok kumar Ojha
Greenhorn

Joined: Jul 18, 2008
Posts: 1
thanks, i was facing the same issue with tomcat, going though suggestions really helped me.
ashwin bala
Ranch Hand

Joined: Dec 07, 2009
Posts: 38
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error running Hibernate Sample Application