title: Hibernate Could not parse mapping document from resource
body: <p>I know this has been asked a dozen times. I must be brain dead today as I've tried modifying my xml file a hundred ways and I can't figure it out. </p>
  
  <p>Error stack when I run the driver:</p>
  
  <pre><code>16 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.2.GA
  31 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
  31 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
  31 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
  78 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: test_hibernate/hibernate.cfg.xml
  78 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: test_hibernate/hibernate.cfg.xml
  125 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : test_hibernate/contact.hbm.xml
  Exception in thread "main" Could not parse mapping document from resource            test_hibernate/contact.hbm.xml
  java.lang.NullPointerException
  at test_hibernate.MyExample.main(MyExample.java:29)
  </code></pre>
  
  <p>Here's the MySQL code for how I built the table:</p>
  
  <pre><code>create database HibernateTest;
  drop table contact;
  Create table CONTACT(
  ID int(15),
  FIRSTNAME varchar(50) ,
  LASTNAME varchar(50),
  EMAIL varchar(150)); 
  describe contact;
  </code></pre>
  
  <p>Here's my mapping file:</p>
  
  <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="test_hibernate.Contact" table="CONTACT"&gt;
  &lt;id name="id" column="ID" &gt;
  &lt;generator class="increment" /&gt;
  &lt;/id&gt;
  &lt;property name="firstName" column="FIRSTNAME" /&gt;
  &lt;property name="lastName" column="LASTNAME" /&gt;
  &lt;property name="email" column="EMAIL" /&gt;
  &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>And here's my config file:</p>
  
  <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;com.mysql.jdbc.Driver&lt;/property&gt;
    &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://localhost/hibernatetest&lt;/property&gt;
    &lt;property name="hibernate.connection.username"&gt;###&lt;/property&gt;
    &lt;property name="hibernate.connection.password"&gt;###&lt;/property&gt;
    &lt;property name="hibernate.connection.pool_size"&gt;10&lt;/property&gt;
    &lt;property name="show_sql"&gt;true&lt;/property&gt;
    &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
    &lt;property name="hibernate.hbm2ddl.auto"&gt;update&lt;/property&gt;
    &lt;!-- Mapping files --&gt;
    &lt;mapping resource="test_hibernate/contact.hbm.xml"/&gt;
  &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>Any help is appreciated, thank you!!</p>
  
  <p>Some additional information: Setup package test_hibernate and here's my persistence file:</p>
  
  <pre><code>package test_hibernate;
  public class Contact {
      private String firstName;
      private String lastName;
      private String email;
      private long id;
  
      public String getEmail() {
          return email;
      }
  
      public String getFirstName() {
          return firstName;
      }
  
      public String getLastName() {
          return lastName;
      }
  
      public void setEmail(String string) {
          email = string;
      }
  
      public void setFirstName(String string) {
          firstName = string;
      }
  
      public void setLastName(String string) {
          lastName = string;
      }
  
      public long getId() {
          return id;
      }
  
      public void setId(long l) {
          id = l;
      }
  }
  </code></pre>
  
  <p>and here's my driver:</p>
  
  <pre><code>package test_hibernate;
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.cfg.Configuration;
  import org.hibernate.Transaction;
  
  public class MyExample {
  
  public static void main(String[] args) {
  Session session = null;
  
  try{
      // This step will read hibernate.cfg.xml and prepare hibernate for use
      SessionFactory sessionFactory = new Configuration().configure("hibernate.cfg.xml").buildSessionFactory();
      session=sessionFactory.openSession();
      Transaction tx = session.beginTransaction();
  
      //Create new instance of Contact and set values in it by reading them from form object
      System.out.println("Inserting Record");
  
      Contact contact = new Contact();
      contact.setId(3);
      contact.setFirstName("Smitha");
      contact.setLastName("Rao");
      contact.setEmail("smithaxxx@yahoo.com");
      session.save(contact);
      tx.commit();
      System.out.println("Done");
  }catch(Exception e){
      System.out.println(e.getMessage());
  }finally{
      // Actual contact insertion will happen at this step
  
      session.flush();        
      session.close();
  }
  }
  }
  </code></pre>