-->
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.  [ 2 posts ] 
Author Message
 Post subject: Mapping fails to parse with discrimator element
PostPosted: Wed Dec 08, 2004 10:56 pm 
Beginner
Beginner

Joined: Fri Aug 27, 2004 1:59 pm
Posts: 33
I'm getting a xml parse error from this mapping. It only occurs if the
discriminator element is present. The mapping validates from within
eclipse, but fails at run-time (ie, when the mapping is added to the
configuration).

This is so simply, its just gotta a stupid user thing, but I just can't see
wha it might be. Any help would be much appreciated.

Hibernate version:
2.1.7

Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping
   package="org.opentrader.brokerdomain.account"
   default-access="field">
   
   <class name="AbstractAccount" lazy="true">
      <id name="id">
         <generator class="native"/>
      </id>
      <version name="version"/>
      
      <discriminator
         column="ACCOUNT_TYPE"
         type="string"/>
   </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
N/A. I am only loading the mapping into the config.

Full stack trace of any exception that occurs:
Code:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [opentrader-brokerdomain-hibernate-ftest.xml]: Initialization of bean failed; nested exception is net.sf.hibernate.MappingException: Error reading resource: org/opentrader/brokerdomain/account/AbstractAccount.hbm.xml
net.sf.hibernate.MappingException: Error reading resource: org/opentrader/brokerdomain/account/AbstractAccount.hbm.xml
   at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:339)
   at org.opentrader.SpringHibernateTestCase$FTestLocalSessionFactoryBean.postProcessConfiguration(SpringHibernateTestCase.java:68)
   at org.springframework.orm.hibernate.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:408)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:990)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:275)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:193)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:240)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:230)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:304)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:80)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
   at org.opentrader.SpringHibernateTestCase.buildApplicationContext(SpringHibernateTestCase.java:31)
   at org.opentrader.SpringHibernateTestCase.setUp(SpringHibernateTestCase.java:43)
   at org.opentrader.brokerdomain.order.SimpleOrderFTest.setUp(SimpleOrderFTest.java:16)
   at junit.framework.TestCase.runBare(TestCase.java:125)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at junit.framework.TestSuite.runTest(TestSuite.java:208)
   at junit.framework.TestSuite.run(TestSuite.java:203)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: net.sf.hibernate.MappingException: invalid mapping
   at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:287)
   at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
   ... 24 more
Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,(cache|jcs-cache)?,(id|composite-id),discriminator?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array)*,(subclass*|joined-subclass*))".
   at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
   at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
   at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
   at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
   at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:2048)
   at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:932)
   at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:713)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
   at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
   at org.dom4j.io.SAXReader.read(SAXReader.java:339)
   at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:286)
   ... 25 more


Name and version of the database you are using:
MySQL 4.1

The generated SQL (show_sql=true):
N/A. Never getting to the database.

Debug level Hibernate log excerpt:
765 [main] INFO net.sf.hibernate.cfg.Configuration - Mapping resource: org/opentrader/brokerdomain/account/AbstractAccount.hbm.xml
781 [main] DEBUG net.sf.hibernate.util.DTDEntityResolver - trying to locate http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath under net/sf/hibernate/
781 [main] DEBUG net.sf.hibernate.util.DTDEntityResolver - found http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath
796 [main] ERROR net.sf.hibernate.util.XMLHelper - Error parsing XML: XML InputStream(16) The content of element type "class" must match "(meta*,(cache|jcs-cache)?,(id|composite-id),discriminator?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array)*,(subclass*|joined-subclass*))".


Top
 Profile  
 
 Post subject: solved
PostPosted: Thu Dec 09, 2004 10:18 am 
Beginner
Beginner

Joined: Fri Aug 27, 2004 1:59 pm
Posts: 33
As I suspected. It was stupid user problem. It was the order of the elements in the mapping. 'discrimator' needs to appear prior to 'version'.

Now I have to find out my MyEclipse XML editor does not valid the order of elements (probably have a builder disabled).


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