-->
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.  [ 3 posts ] 
Author Message
 Post subject: Document root element "hibernate-mapping", must ma
PostPosted: Wed Mar 11, 2009 9:14 am 
Newbie

Joined: Wed Mar 11, 2009 8:31 am
Posts: 5
Hello, all!

problem:
+-----------------------------------------------------------------------------+
%tomcat_home%\logs\stdout_20090311.log:
+-----------------------------------------------------------------------------+
14:27:35,406 INFO Environment:520 - Hibernate 3.3.0.CR1
14:27:35,406 INFO Environment:553 - hibernate.properties not found
14:27:35,406 INFO Environment:687 - Bytecode provider name : cglib
14:27:35,421 INFO Environment:604 - using JDK 1.4 java.sql.Timestamp handling
14:27:35,500 INFO Configuration:1437 - configuring from resource: /hibernate.cfg.xml
14:27:35,515 INFO Configuration:1414 - Configuration resource: /hibernate.cfg.xml
14:27:35,593 INFO Configuration:563 - Reading mappings from resource : springapp/domain/Product.hbm.xml
14:27:35,593 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(6) Document root element "hibernate-mapping", must match DOCTYPE root "hibernate-configuration".
14:27:35,593 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(6) Element type "hibernate-mapping" must be declared.
14:27:35,593 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(7) Element type "class" must be declared.
14:27:35,593 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(9) Element type "id" must be declared.
14:27:35,593 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(10) Element type "generator" must be declared.
14:27:35,593 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(13) Attribute "column" must be declared for element type "property".
14:27:35,609 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(13) Attribute "type" must be declared for element type "property".
14:27:35,609 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(14) Attribute "column" must be declared for element type "property".
14:27:35,609 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(14) Attribute "type" must be declared for element type "property".
Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource springapp/domain/Product.hbm.xml
+-----------------------------------------------------------------------------+

settings:
+-----------------------------------------------------------------------------+
hibernate.cfg.xml:
+-----------------------------------------------------------------------------+
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>
<property name="connection.url">jdbc:mysql://localhost/test</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.username">root</property>
<property name="connection.password">1</property>
<property name="connection.pool_size">1</property>
<property name="current_session_context_class">thread</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>

<mapping resource="springapp/domain/Product.hbm.xml"/>
</session-factory>

</hibernate-configuration>
+-----------------------------------------------------------------------------+
Product.hbm.xml:
+-----------------------------------------------------------------------------+
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-mapping>
<class name="springapp.domain.Product" table="products">

<id column="id" name="id" type="java.lang.Long">
<generator class="increment"/>
</id>

<property column="description" name="description" type="java.lang.String"/>
<property column="price" name="price" type="java.lang.String"/>

</class>
</hibernate-mapping>
+-----------------------------------------------------------------------------+
Product.java:
+-----------------------------------------------------------------------------+
package springapp.domain;

import java.io.Serializable;

public class Product implements Serializable {

private int id;
private String description;
private Double price;

public void setId(int i) {
id = i;
}

public int getId() {
return id;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public Double getPrice() {
return price;
}

public void setPrice(Double price) {
this.price = price;
}

public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("Description: " + description + ";");
buffer.append("Price: " + price);
return buffer.toString();
}
}
+-----------------------------------------------------------------------------+
my db schema locate: http://forum.springframework.org/attachment.php?attachmentid=2003&d=1236777040
my project schema locate: http://forum.springframework.org/attachment.php?attachmentid=2004&d=1236777046
+-----------------------------------------------------------------------------+

Please help me to solve this problem.

Thanks in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 11, 2009 3:13 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
The <!DOCTYPE> declaration in your Product.hbm.xml is incorrect. It should be:

Code:
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">


Top
 Profile  
 
 Post subject: many thanks!
PostPosted: Thu Mar 12, 2009 2:35 am 
Newbie

Joined: Wed Mar 11, 2009 8:31 am
Posts: 5
thanks, it help me!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.