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