title: H2 DB -- Hibernate Example -- Could not parse mapping document from resource
body: <h1>* Each of below files are in same location *</h1>
  
  <h1>Error :</h1>
  
  <pre>
  
      SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
      SLF4J: Defaulting to no-operation (NOP) logger implementation
      SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
  org.hibernate.InvalidMappingException: Could not parse mapping document from resource ./employee.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.yahoo.hibernatelearning.FirstExample.main(FirstExample.java:19)
  Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
      at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:555)
      at org.hibernate.cfg.Configuration.addResource(Configuration.java:613)
      ... 7 more
  Caused by: org.dom4j.DocumentException: http://hibernate.sourceforge.net/%0Ahibernate-mapping-3.0.dtd Nested exception: http://hibernate.sourceforge.net/%0Ahibernate-mapping-3.0.dtd
      at org.dom4j.io.SAXReader.read(SAXReader.java:484)
      at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:546)
      ... 8 more
  Exception in thread "main" java.lang.NullPointerException
      at com.yahoo.hibernatelearning.FirstExample.main(FirstExample.java:33)
  
  </pre>
  
  <h1>Hibernate Config: hibernate.cfg.xml</h1>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
  "-//Hibernate/Hibernate Configuration DTD//EN"
  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
  &lt;session-factory&gt;
  &lt;property name="hibernate.connection.driver_class"&gt;org.h2.Driver&lt;/property&gt;
  &lt;property name="hibernate.connection.url"&gt;jdbc:h2:./db/repository&lt;/property&gt;
  &lt;property name="hibernate.connection.username"&gt;sa&lt;/property&gt;
  &lt;property name="hibernate.connection.password"&gt;&lt;/property&gt;
  &lt;property name="hibernate.default_schema"&gt;PUBLIC&lt;/property&gt;
  &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.H2Dialect&lt;/property&gt;
  &lt;property name="hibernate.show_sql"&gt;true&lt;/property&gt;
  &lt;property name="hibernate.hbm2ddl.auto"&gt;update&lt;/property&gt;
  &lt;!--  Mapping files  --&gt;
  &lt;mapping resource="./employee.hbm.xml"/&gt;
  &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <h1>Mapping Config: employee.hbm.xml</h1>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC
  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  "http://hibernate.sourceforge.net/
  hibernate-mapping-3.0.dtd"&gt;
  &lt;hibernate-mapping&gt;
  &lt;class name="com.yahoo.hibernatelearning.Employee" table="employee"&gt;
  &lt;id name="empId" type="int" column="emp_id" &gt;
  &lt;generator class="native"/&gt;
  &lt;/id&gt;
  &lt;property name="empName"&gt;
  &lt;column name="emp_name" /&gt;
  &lt;/property&gt;
  &lt;property name="empSal"&gt;
  &lt;column name="emp_sal" /&gt;
  &lt;/property&gt;
  &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <h1>Mapping Class : Employee.java</h1>
  
  <pre>
  
      package com.yahoo.hibernatelearning;
  
      public class Employee {
  
          private int empId;
          private String empName;
          private int empSal;
  
          public int getEmpId() {
              return empId;
          }   
  
          public void setEmpId(int empId) {
              this.empId = empId;
          }
  
          public String getEmpName() {
              return empName;
          }
  
          public void setEmpName(String empName) {
          this.empName = empName;
          }
  
          public int getEmpSal() {
              return empSal;
          }
  
          public void setEmpSal(int empSal) {
              this.empSal = empSal;
          }
  
      }
  </pre>
  
  <h1>Code: FirstExample.java</h1>
  
  <pre>
  
      package com.yahoo.hibernatelearning;
  
      import org.hibernate.Session;
      import org.hibernate.SessionFactory;
      import org.hibernate.Transaction;
      import org.hibernate.cfg.Configuration;
  
      public class FirstExample {
  
      /**
      * @param args
      */
      public static void main(String[] args) {
      // TODO Auto-generated method stub
  
      Session sess = null;
      Transaction tran = null;
      try{
      SessionFactory sessFact = new Configuration().configure().buildSessionFactory();
      sess = sessFact.openSession();
      System.out.println("Session: "+ sess);
      tran = sess.beginTransaction();
      Employee emp = new Employee();
      emp.setEmpName("Birendra Kumar");
      emp.setEmpSal(12000);
      sess.save(emp);
      tran.commit();
      }
      catch(Exception ex){
      ex.printStackTrace();
      }
      finally{
      sess.close();
      }
  
      }
  
      }
  
  </pre>