-->
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: Attribute "type" must be declared for element type
PostPosted: Mon Jun 27, 2005 3:15 pm 
Newbie

Joined: Mon Jun 27, 2005 3:01 pm
Posts: 3
hello,
i'm using Hibernate 3.0.4 and oracle.
i got this Group class with the following mapping:
Code:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="fdms.accounts">
     <class name="fdms.accounts.Group" table="GROUPS">
      <id name="groupID" column="GROUPID" type="int" unsaved-value="0">
         <generator class="org.hibernate.id.IncrementGenerator"/>
      </id>
          <property name="groupName" column="GROUPNAME" type="string" length="128" not-null="true"/>
          <property name="groupDescription" column="GROUPDESCRIPTION" type="string" length="256" />
      
      <set name="groupUsers" table="GROUPS_USERS">
         <key  column="GROUPID" type="int"  />
         <many-to-many column="USERID" class="fdms.accounts.User" />
      </set>
     </class>
</hibernate-mapping>

when i run the servlet i get this exception:
Code:
2005-06-27 20:58:15,565 [http-8080-Processor25] ERROR org.hibernate.util.XMLHelper - Error parsing XML: XML InputStream(14) Attribute "type" must be declared for element type "key".
2005-06-27 20:58:15,575 [http-8080-Processor25] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/fdms].[fdmsServlet] - Servlet.service() for servlet fdmsServlet threw exception
org.hibernate.MappingException: Error reading resource: fdms/accounts/Group.hbm.xml
   at org.hibernate.cfg.Configuration.addResource(Configuration.java:452)
   at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1263)
   at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1235)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1217)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1184)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
   at fdms.HibernateSession.currentSession(HibernateSession.java:22)
   at fdms.fdmsServlet.showGroupsList(fdmsServlet.java:270)
   at fdms.fdmsServlet.doGet(fdmsServlet.java:97)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.MappingException: invalid mapping
   at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:399)
   at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
   ... 25 more
Caused by: org.xml.sax.SAXParseException: Attribute "type" must be declared for element type "key".
   at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
   at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
   at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
   at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
   at org.apache.xerces.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(Unknown Source)
   at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
   at org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
   at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
   at org.dom4j.io.SAXReader.read(SAXReader.java:465)
   at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:398)
   ... 26 more


pay attention to the line:

Caused by: org.xml.sax.SAXParseException: Attribute "type" must be declared for element type "key".

the thing is that i [b]do[b/] have a "type" attribute in the key element!!

does anyone has an idea?

PS: you can assume that the related User class is fine.


Top
 Profile  
 
 Post subject: Re: Attribute "type" must be declared for element
PostPosted: Mon Jun 27, 2005 4:22 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
israelk wrote:
hello,
i'm using Hibernate 3.0.4 and oracle.
i got this Group class with the following mapping:
Code:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="fdms.accounts">
     <class name="fdms.accounts.Group" table="GROUPS">
      <id name="groupID" column="GROUPID" type="int" unsaved-value="0">
         <generator class="org.hibernate.id.IncrementGenerator"/>
      </id>
          <property name="groupName" column="GROUPNAME" type="string" length="128" not-null="true"/>
          <property name="groupDescription" column="GROUPDESCRIPTION" type="string" length="256" />
      
      <set name="groupUsers" table="GROUPS_USERS">
         <key  column="GROUPID" type="int"  />
         <many-to-many column="USERID" class="fdms.accounts.User" />
      </set>
     </class>
</hibernate-mapping>


pay attention to the line:

Caused by: org.xml.sax.SAXParseException: Attribute "type" must be declared for element type "key".

the thing is that i [b]do[b/] have a "type" attribute in the key element!!

does anyone has an idea?

PS: you can assume that the related User class is fine.


is "int" a valid Hibernate type ? I don't think it is... I think it should be type="integer".


Top
 Profile  
 
 Post subject: Re: Attribute "type" must be declared for element
PostPosted: Mon Jun 27, 2005 4:23 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
pksiv wrote:
israelk wrote:
hello,
i'm using Hibernate 3.0.4 and oracle.
i got this Group class with the following mapping:
Code:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="fdms.accounts">
     <class name="fdms.accounts.Group" table="GROUPS">
      <id name="groupID" column="GROUPID" type="int" unsaved-value="0">
         <generator class="org.hibernate.id.IncrementGenerator"/>
      </id>
          <property name="groupName" column="GROUPNAME" type="string" length="128" not-null="true"/>
          <property name="groupDescription" column="GROUPDESCRIPTION" type="string" length="256" />
      
      <set name="groupUsers" table="GROUPS_USERS">
         <key  column="GROUPID" type="int"  />
         <many-to-many column="USERID" class="fdms.accounts.User" />
      </set>
     </class>
</hibernate-mapping>


pay attention to the line:

Caused by: org.xml.sax.SAXParseException: Attribute "type" must be declared for element type "key".

the thing is that i [b]do[b/] have a "type" attribute in the key element!!

does anyone has an idea?

PS: you can assume that the related User class is fine.


is "int" a valid Hibernate type ? I don't think it is... I think it should be type="integer".


I'm pretty sure I'm wrong above.


Top
 Profile  
 
 Post subject: Re: Attribute "type" must be declared for element
PostPosted: Mon Jun 27, 2005 4:50 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
israelk wrote:
hello,
i'm using Hibernate 3.0.4 and oracle.
i got this Group class with the following mapping:
Code:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="fdms.accounts">
     <class name="fdms.accounts.Group" table="GROUPS">
      <id name="groupID" column="GROUPID" type="int" unsaved-value="0">
         <generator class="org.hibernate.id.IncrementGenerator"/>
      </id>
          <property name="groupName" column="GROUPNAME" type="string" length="128" not-null="true"/>
          <property name="groupDescription" column="GROUPDESCRIPTION" type="string" length="256" />
      
      <set name="groupUsers" table="GROUPS_USERS">
         <key  column="GROUPID" type="int"  />
         <many-to-many column="USERID" class="fdms.accounts.User" />
      </set>
     </class>
</hibernate-mapping>


pay attention to the line:

Caused by: org.xml.sax.SAXParseException: Attribute "type" must be declared for element type "key".

the thing is that i [b]do[b/] have a "type" attribute in the key element!!

does anyone has an idea?

PS: you can assume that the related User class is fine.


The parser is complaining because you are providing an attribute that is not defined in the DTD. Their is no type attribute for the key element under set.


Top
 Profile  
 
 Post subject: Tjabk you all!!
PostPosted: Tue Jun 28, 2005 1:35 am 
Newbie

Joined: Mon Jun 27, 2005 3:01 pm
Posts: 3
It worked like a charm...
(deleting the type attribute from the key element..)
I wonder why in the hibernate documentation they do it with a type attribute..


THANX ALLOT!!!


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.