-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Problem with Tutorial included with Hibernate, chapter 1
PostPosted: Wed Jun 11, 2008 6:55 am 
Newbie

Joined: Wed Jun 11, 2008 6:37 am
Posts: 3
Location: UK
Hi,

I've got as far with the tutorial as:
$ ant run -Daction=store
whereupon it builds successfully & then falls over with the following error:
[java] 11:18:59,122 INFO Configuration:559 - Reading mappings from resource : events/Event.hbm.xml
[java] 11:18:59,129 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(1) Document is invalid: no grammar found.
[java] 11:18:59,130 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(1) Document root element "hibernate-mapping", must match DOCTYPE root "null".
[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)
...(rest of stack trace snipped for brevity)

I'm assuming that the problem is with Event.hbm.xml as that was the last thing it was doing, but I've checked & the file is the same as in the tutorial (I used copy/paste rather than typing it all in) & located in the tutorial/src/event/ package folder along with Event.java. Why's it doing this?

Here's my Event.hbm.xml file:
<hibernate-mapping>

<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>

</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: Problem with Tutorial included with Hibernate, chapter 1
PostPosted: Wed Jun 11, 2008 8:03 am 
Newbie

Joined: Wed Jun 11, 2008 6:37 am
Posts: 3
Location: UK
Sciamachy wrote:
Hi,

I've got as far with the tutorial as:
$ ant run -Daction=store
whereupon it builds successfully & then falls over with the following error:
[java] 11:18:59,122 INFO Configuration:559 - Reading mappings from resource : events/Event.hbm.xml
[java] 11:18:59,129 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(1) Document is invalid: no grammar found.
[java] 11:18:59,130 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(1) Document root element "hibernate-mapping", must match DOCTYPE root "null".
[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)
...(rest of stack trace snipped for brevity)

I'm assuming that the problem is with Event.hbm.xml as that was the last thing it was doing, but I've checked & the file is the same as in the tutorial (I used copy/paste rather than typing it all in) & located in the tutorial/src/event/ package folder along with Event.java. Why's it doing this?

Here's my Event.hbm.xml file:
<hibernate-mapping>

<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>

</hibernate-mapping>



Gah - I'm an eeejit! I left off the XML header from the .hbm.xml file! Problem solved.


Top
 Profile  
 
 Post subject: Tutorial - Event.hbm.xml issue
PostPosted: Thu Jun 12, 2008 4:03 pm 
Newbie

Joined: Thu Jun 12, 2008 3:58 pm
Posts: 1
I follow the tutorial to create Event.hbm.xml but I got the error when I run it.

[java] 15:55:54,746 INFO Configuration:559 - Reading mappings from resource : events/Event.hbm.xml
[java] 15:55:54,756 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(2) Document is invalid: no grammar found.
[java] 15:55:54,766 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(2) Document root element "hibernate-mapping", must match DOCTYPE root "null".
[java] Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource events/Event.hbm.xml

Here's the contents in Event.hbm.xml
<hibernate-mapping>
<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>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 12, 2008 4:40 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Sometimes the simplest problems are the toughest ones to solve.

Onwards and upwards!

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Re: Tutorial - Event.hbm.xml issue
PostPosted: Thu Jun 12, 2008 6:18 pm 
Newbie

Joined: Wed Jun 11, 2008 6:37 am
Posts: 3
Location: UK
mikehsieh wrote:
I follow the tutorial to create Event.hbm.xml but I got the error when I run it.

[java] 15:55:54,746 INFO Configuration:559 - Reading mappings from resource : events/Event.hbm.xml
[java] 15:55:54,756 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(2) Document is invalid: no grammar found.
[java] 15:55:54,766 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(2) Document root element "hibernate-mapping", must match DOCTYPE root "null".
[java] Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource events/Event.hbm.xml

Here's the contents in Event.hbm.xml
<hibernate-mapping>
<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>
</hibernate-mapping>


Yes, to clarify, what we've both left out is the XML header, which looks like this:
Quote:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

...and goes just above the <hibernate-mapping>...etc.

Once that's in, it sorts it out nicely. It's mentioned in the tutorial but because the whole file isn't quoted as one piece, us copy-pastafarians end up copying half a file.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.