title: org.hibernate.InvalidMappingException:Could not parse mapping document from resource com/lara/Person.hbm.xml
body: <pre><code>Exception in thread "main" org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/lara/Person.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 com.lara.Manager.main(Manager.java:15)
  Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
      at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:549)
      at org.hibernate.cfg.Configuration.addResource(Configuration.java:613)
      ... 7 more
  Caused by: org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 39; Document root element "hibernate-mapping", must match DOCTYPE root "hibernate-configuration".
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.rootElementSpecified(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
      at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
      at org.dom4j.io.SAXReader.read(SAXReader.java:465)
      at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:546)
      ... 8 more
  </code></pre>
  
  <h1>hibernate.cfg.xml</h1>
  
  <pre><code>        &lt;?xml version='1.0' encoding='utf-8'?&gt;
         &lt;!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
          &lt;hibernate-configuration&gt;
  
      &lt;session-factory&gt;
  
          &lt;!-- Database connection settings --&gt;
          &lt;property name="connection.driver_class"&gt;oracle.jdbc.driver.OracleDriver&lt;/property&gt;
          &lt;property name="connection.url"&gt;jdbc:oracle:thin:@localhost:1521:XE&lt;/property&gt;
          &lt;property name="connection.username"&gt;system&lt;/property&gt;
          &lt;property name="connection.password"&gt;system&lt;/property&gt;
  
          &lt;!-- JDBC connection pool (use the built-in) --&gt;
          &lt;property name="connection.pool_size"&gt;2&lt;/property&gt;
  
          &lt;!-- SQL dialect --&gt;
          &lt;property name="dialect"&gt;org.hibernate.dialect.OracleDialect&lt;/property&gt;
  
          &lt;!-- Enable Hibernate's current session context --&gt;
          &lt;property name="current_session_context_class"&gt;org.hibernate.context.ManagedSessionContext&lt;/property&gt;
  
          &lt;!-- Disable the second-level cache  --&gt;
          &lt;property name="cache.provider_class"&gt;org.hibernate.cache.NoCacheProvider&lt;/property&gt;
  
          &lt;!-- Echo all executed SQL to stdout --&gt;
          &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
          &lt;!-- Drop and re-create the database schema on startup --&gt;
          &lt;property name="hbm2ddl.auto"&gt;create&lt;/property&gt;
  
  
          &lt;mapping resource="com/lara/Person.hbm.xml"/&gt;
  
      &lt;/session-factory&gt;
  
       &lt;/hibernate-configuration&gt;
  
  
  
  
  Person.hbm.xml
  ==============
          &lt;?xml version='1.0' encoding='utf-8'?&gt;
          &lt;!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  
  
          &lt;hibernate-mapping package="com.lara"&gt;
  
      &lt;class name="Person" table="PERSON"&gt;
          &lt;id name="id" column="PERSON_ID"&gt;
              &lt;generator class="native" /&gt;
          &lt;/id&gt;
          &lt;property name="age"/&gt;
          &lt;property name="firstname"/&gt;
          &lt;property name="lastname"/&gt;
  
      &lt;/class&gt;
  
          &lt;/hibernate-mapping&gt;
  
  
  Person.java
  =============
          package com.lara;
  
          public class Person {
      private int id;
      private String firstName;
      private String lastName;
      private int age;
  
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public String getFirstName() {
          return firstName;
      }
  
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
  
      public String getLastName() {
          return lastName;
      }
  
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }
  
      public int getAge() {
          return age;
      }
  
      public void setAge(int age) {
          this.age = age;
      }
  
        }
  
  Manager.java
  =============
          package com.lara;
  
          import org.hibernate.Session;
          import org.hibernate.SessionFactory;
          import org.hibernate.cfg.Configuration;
  
          public class Manager {
  
      public static void main(String[] args) {
          Person p1 = new Person();
          p1.setFirstName("abc");
          p1.setLastName("xyz");
          p1.setAge(22);
  
          Configuration c1 = new Configuration().configure();
  
          SessionFactory sf = c1.buildSessionFactory();
          Session s1 = sf.openSession();
  
          s1.beginTransaction();
          s1.save(p1);
          s1.getTransaction().commit();
  
          s1.flush();
          s1.close();
          System.out.println("done");
       }
         }
  </code></pre>