Could not parse mapping document from resource Cn/spt/model/student.hbm.xml

Source: Internet
Author: User

Initial hibernate, write the first program HelloWorld error:

Exception in thread "main" Org.hibernate.InvalidMappingException:Could not parse mapping document from resource Cn/spt/mo Del/student.hbm.xml at Org.hibernate.cfg.Configuration.addResource (configuration.java:616) at Org.hibernate.cfg.Configuration.parseMappingElement (configuration.java:1635) at Org.hibernate.cfg.Configuration.parseSessionFactory (configuration.java:1603) at Org.hibernate.cfg.Configuration.doConfigure (configuration.java:1582) at Org.hibernate.cfg.Configuration.doConfigure (configuration.java:1556) at Org.hibernate.cfg.Configuration.configure (configuration.java:1476) at Org.hibernate.cfg.Configuration.configure ( configuration.java:1462) at Cn.spt.mgr.StudentManager.main (studentmanager.java:22) caused by: Org.hibernate.InvalidMappingException:Could not parse mapping document from invalid mapping at ORG.HIBERNATE.CFG.CONFI Guration.addinputstream (configuration.java:549) at Org.hibernate.cfg.Configuration.addResource ( configuration.java:613) ...7 morecaused by:org.xml.sax.SAXParseException; linenumber:1; columnnumber:19;    Invalid document: syntax not found. At Com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException (Errorhandlerwrapper.java : 198) at Com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error (errorhandlerwrapper.java:134) at Com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError (xmlerrorreporter.java:437) at Com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError (xmlerrorreporter.java:368) at Com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError (xmlerrorreporter.java:325) at Com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement ( xmlnsdocumentscannerimpl.java:228) at com.sun.org.apache.xerces.internal.impl.xmlnsdocumentscannerimpl$ Nscontentdriver.scanrootelementhook (xmlnsdocumentscannerimpl.java:605) at Com.sun.org.apache.xerces.internal.impl.xmldocumentfragmentscannerimpl$fragmentcontentdriver.next (XMLDocumentfragmentscannerimpl.java:3138) at com.sun.org.apache.xerces.internal.impl.xmldocumentscannerimpl$ Prologdriver.next (xmldocumentscannerimpl.java:880) at Com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next (xmldocumentscannerimpl.java:606) at Com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next (xmlnsdocumentscannerimpl.java:117) at Com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument ( xmldocumentfragmentscannerimpl.java:510) at Com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse ( xml11configuration.java:848) at Com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse ( xml11configuration.java:777) at Com.sun.org.apache.xerces.internal.parsers.XMLParser.parse (xmlparser.java:141) at Com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse (abstractsaxparser.java:1213) at  Com.sun.org.apache.xerces.internal.jaxp.saxparserimpl$jaxpsaxparser.parse (saxparserimpl.java:648)  At Org.dom4j.io.SAXReader.read (saxreader.java:465) at Org.hibernate.cfg.Configuration.addInputStream ( configuration.java:546) ... 8 more

Google, found the need to be mapping in the Cn/spt/model/student.hbm.xml configuration file header to add the following information:

<? XML version= "1.0" encoding= "Utf-8" ?> <! DOCTYPE hibernate-mapping Public "-//hibernate/hibernate mapping DTD 3.0//en" "http://hibernate.sourceforge.net/ Hibernate-mapping-3.0.dtd ">

Could not parse mapping document from resource Cn/spt/model/student.hbm.xml

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.