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: org.xml.sax.SAXParseException: Attribute "name" mu
PostPosted: Tue Dec 07, 2004 7:24 pm 
Newbie

Joined: Sat Dec 04, 2004 10:23 pm
Posts: 13
Hibernate version: 2.1.6

I have following mapping files
User mapping file contains list of orders (one to many)
Order contians( many to one)
I am getting invalid mapping exception
I don't know where i am going wrong


mapping documents

UserData.hbm.xml


<?xml version="1.0" encoding="UTF-8"?>

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

<hibernate-mapping
>
<class
name="Model.UserData"
table="UserData"
>

<id
name="userID"
column="userID"
type="int"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-UserData.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

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

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

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

<property
name="expiryDate"
type="java.util.Date"
column="expiryDate"
/>

<!-- <property
name="orderData"
type="java.util.List"
column="orderData"
/>
-->

<list name="OrderData" role="OrderData" lazy="true" >
<key column="userID" />

<one-to-many class="Model.OrderData" />
</list>

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

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

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-UserData.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


OrderData.hbm.xml


<?xml version="1.0" encoding="UTF-8"?>

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

<hibernate-mapping
>
<class
name="Model.OrderData"
table="OrderData"
>

<id
name="orderId"
column="OrderId"
type="int"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-OrderData.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="billingAddress"
type="java.lang.String"
column="BillingAddress"
/>

<list
role="bookData"
lazy="true"
cascade="none"
>

<key
column="OrderId"
>
</key>

<one-to-many
class="Model.BookData"
/>

</list>

<property
name="shippingAddress"
type="java.lang.String"
column="ShippingAddress"
/>

<many-to-one
name="UserData"
<!-- class="UserData" -->


column="userId"
not-null="true"

/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-OrderData.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>




Error messages

[java] net.sf.hibernate.MappingException: Error reading resource: Model/Use
ta.hbm.xml
[java] at net.sf.hibernate.cfg.Configuration.addResource(Configuration.
a:339)
[java] at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.
a:1013)
[java] at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.
a:969)
[java] at net.sf.hibernate.cfg.Configuration.configure(Configuration.ja
897)
[java] at net.sf.hibernate.cfg.Configuration.configure(Configuration.ja
883)
[java] at Model.UserOperations.configureHibernate(UserOperations.java:8

[java] at Model.UserOperations.<init>(UserOperations.java:42)
[java] at gui.LoginView.<init>(LoginView.java:15)
[java] at gui.LoginView.main(LoginView.java:115)
[java] Caused by: net.sf.hibernate.MappingException: invalid mapping
[java] at net.sf.hibernate.cfg.Configuration.addInputStream(Configurati
java:287)
[java] at net.sf.hibernate.cfg.Configuration.addResource(Configuration.
a:336)
[java] ... 8 more
[java] Caused by: org.xml.sax.SAXParseException: Attribute "name" must be d
ared for element type "list".
[java] at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseExce
on(Unknown Source)
[java] at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Sour

[java] at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown S
ce)
[java] at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown S
ce)
[java] at org.apache.xerces.impl.dtd.XMLDTDValidator.addDTDDefaultAttrs
Validate(Unknown Source)
[java] at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement
known Source)
[java] at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unkno
Source)
[java] at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElem
(Unknown Source)
[java] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$Fragmen
ntentDispatcher.dispatch(Unknown Source)
[java] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDoc
nt(Unknown Source)
[java] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown So
e)
[java] at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Sour

[java] at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
[java] at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Sou
)
[java] at org.dom4j.io.SAXReader.read(SAXReader.java:339)
[java] at net.sf.hibernate.cfg.Configuration.addInputStream(Configurati
java:286)
[java] ... 9 more
[java] Java Result: 1


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 07, 2004 7:57 pm 
Newbie

Joined: Thu Oct 28, 2004 9:36 pm
Posts: 9
Location: Melbourne, Australia
As the error says in the stack trace you are missing a "name" attribute in your "list" element.

Code:
<list
role="bookData"
lazy="true"
cascade="none"
>


The DTD says it is required.
Code:
<!ATTLIST list name CDATA #REQUIRED>


See the DTD for all mapping document rules...
http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 07, 2004 8:14 pm 
Newbie

Joined: Sat Dec 04, 2004 10:23 pm
Posts: 13
i changed taht now
still i getting same error

Now that bookdata list looks like this in orderdata.hbm.xml

<list name="BookData"
role="BookData"
table="BookData"
lazy="true"
cascade="none"
>
<key
column="orderId"
>
</key>

<one-to-many
class="BookData"
/>

</list>

previosli i haven't posted bookdata.hbm.xml

Bookdata.hbm.xml


<?xml version="1.0" encoding="UTF-8"?>

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

<hibernate-mapping
>
<class
name="BookData"
table="BookData"
>

<id
name="isbn"
column="isbn"
type="int"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-BookData.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

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

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

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

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

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

<property
name="contents"
type="java.lang.String"
column="content"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-BookData.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 07, 2004 8:30 pm 
Newbie

Joined: Thu Oct 28, 2004 9:36 pm
Posts: 9
Location: Melbourne, Australia
I think if you read the stack trace carefully you will see the error, just as I did before.

Also, as mentioned above, see the DTD. It is unambiguous in what is legal syntax for a mapping document.

These are simple syntax errors. Take the time to look closely. Debugging via forum posts is slow for everyone.

If you can't spot the error, comment out everything in the mapping document and start again, umcommenting sections until you get the error again.

Good luck


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 12:01 am 
Newbie

Joined: Sat Dec 04, 2004 10:23 pm
Posts: 13
thank u for ur guidence

I have checked everything

Still i not able find the error in xml 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.