title: org.hibernate.InvalidMappingException: Could not parse mapping document from resource *.hbm.xml
body: <p>I know this question has been asked a lot, but I read almost every one of them but non of them helped me.
  I'm writing an eclipse maven project with hibernate and I'm getting this error:</p>
  
  <pre><code>org.hibernate.InvalidMappingException: Could not parse mapping document from resource ir/ac/ut/ieproj/da/Student.hbm.xml
  </code></pre>
  
  <p>my files are like this:</p>
  
  <p>pom.xml</p>
  
  <pre><code>    &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
    &lt;groupId&gt;ir.ac.ut&lt;/groupId&gt;
    &lt;artifactId&gt;ieproj&lt;/artifactId&gt;
    &lt;version&gt;0.2&lt;/version&gt;
    &lt;packaging&gt;war&lt;/packaging&gt;
  
    &lt;name&gt;ieproj&lt;/name&gt;
    &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
    &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;/properties&gt;
  
  &lt;build&gt;
  
      &lt;resources&gt;
        &lt;resource&gt;
          &lt;directory&gt;src/main/java&lt;/directory&gt;
          &lt;filtering&gt;true&lt;/filtering&gt;
        &lt;/resource&gt;
      &lt;/resources&gt;
  
     &lt;plugins&gt;
     &lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
      &lt;version&gt;2.0&lt;/version&gt;
      &lt;/plugin&gt;
      &lt;plugin&gt;
  
      &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
      &lt;version&gt;2.2&lt;/version&gt;
      &lt;configuration&gt;
          &lt;descriptorRefs&gt;
              &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt;
          &lt;/descriptorRefs&gt;
      &lt;/configuration&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;id&gt;make-assembly&lt;/id&gt;
              &lt;phase&gt;package&lt;/phase&gt;
              &lt;goals&gt;
                  &lt;goal&gt;single&lt;/goal&gt;
              &lt;/goals&gt;
          &lt;/execution&gt;
      &lt;/executions&gt;
  
      &lt;/plugin&gt;
     &lt;/plugins&gt;
  
  &lt;/build&gt;
  
      &lt;repositories&gt;
          &lt;repository&gt;
              &lt;id&gt;JBoss repository&lt;/id&gt;
              &lt;url&gt;http://repository.jboss.org/nexus/content/groups/public/&lt;/url&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
  
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;3.8.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;ir.ac.ut&lt;/groupId&gt;
          &lt;artifactId&gt;iecommon&lt;/artifactId&gt;
          &lt;version&gt;1.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;version&gt;5.1.24&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
          &lt;version&gt;2.5&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
          &lt;version&gt;3.5.1-Final&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
          &lt;version&gt;3.5.1-Final&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
          &lt;version&gt;1.7.4&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;dom4j&lt;/groupId&gt;
          &lt;artifactId&gt;dom4j&lt;/artifactId&gt;
          &lt;version&gt;1.6.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
          &lt;version&gt;5.0.1.Final&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate&lt;/artifactId&gt;
          &lt;version&gt;3.5.4-Final&lt;/version&gt;
          &lt;type&gt;pom&lt;/type&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;log4j&lt;/groupId&gt;
          &lt;artifactId&gt;log4j&lt;/artifactId&gt;
          &lt;version&gt;1.2.17&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
          &lt;version&gt;1.7.4&lt;/version&gt;
      &lt;/dependency&gt;
  
    &lt;/dependencies&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>hibernate.cfg.xml</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:3306/db&lt;/property&gt;
        &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
        &lt;property name="hibernate.connection.password"&gt;13812002&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="ir/ac/ut/ieproj/da/Department.hbm.xml"/&gt;
        &lt;mapping resource="ir/ac/ut/ieproj/da/Studyrec.hbm.xml"/&gt;
        &lt;mapping resource="ir/ac/ut/ieproj/da/Student.hbm.xml"/&gt;
  &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>Department.hbm.xml</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 package="ir.ac.ut.ieproj.da"&gt;
      &lt;class name="DepartmentRepo" table="department"&gt;
                &lt;id name="id" type="int" column="ID" &gt;
                  &lt;generator class="assigned"/&gt;           
                &lt;/id&gt;
                &lt;property name="name" column="Name" type="string"/&gt;
      &lt;/class&gt;
  
      &lt;sql-query name="getDeptName"&gt;
          &lt;return alias="Department" class="DepartmentRepo"/&gt;
          &lt;![CDATA[select * from db.department d where d.ID = :id]]&gt;
      &lt;/sql-query&gt;
  
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>Student.hbm.xml</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 package="ir.ac.ut.ieproj.da"&gt;
      &lt;class name="StudentRepo" table="student"&gt;
                &lt;id name="id" type="int" column="ID" &gt;
                  &lt;generator class="assigned"/&gt;           
                &lt;/id&gt;
                &lt;property name="firstName" type="string" column="FirstName" /&gt;
                &lt;/property&gt;
                &lt;property name="lastName" type="string" column="LastName"/&gt;
                &lt;/property&gt;
                &lt;property name="program" type="string" column="Program"/&gt;
                &lt;/property&gt;
                &lt;many-to-one
                  name="dept"
                  class="DepartmentRepo"
                  cascade="all"
                  not-null="true"
                  column="deptId"/&gt;
      &lt;/class&gt;
  
      &lt;sql-query name="findStudentId"&gt;
          &lt;return alias="Student" class="StudentRepo"/&gt;
          &lt;![CDATA[select * from db.student s where s.ID = :sid]]&gt;
      &lt;/sql-query&gt;
  
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>StudentRepo.java</p>
  
  <pre><code>package ir.ac.ut.ieproj.da;
  
  import ir.ac.ut.ieproj.model.Student;
  
  import org.hibernate.HibernateException;
  import org.hibernate.MappingException;
  import org.hibernate.Query;
  import org.hibernate.Session;
  import org.hibernate.Transaction;
  
  public class StudentRepo {
  
      private int id;
      private String firstName;
      private String lastName;
      private String program;
      private DepartmentRepo dept;
  
      public Student getStudentbyId (String sid) throws MappingException, HibernateException, Exception {
  
          Student student = new Student();
          Session session = HibernateUtil.getHibernateSession();
          Transaction tx = session.beginTransaction();
          Query query = session.getNamedQuery("findStudentId").setLong("sid", Long.valueOf(sid));
          StudentRepo studentRepo = (StudentRepo) query.uniqueResult();
          student.setId(studentRepo.getId());
          student.setFirstName(studentRepo.getFirstName());
          student.setLastName(studentRepo.getLastName());
          student.setProgram(Integer.valueOf(studentRepo.getProgram()));
          tx.commit();
          session.close();
  
          return student;
  
      }
  
      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 String getProgram() {
          return program;
      }
  
      public void setProgram(String program) {
          this.program = program;
      }
  
      public DepartmentRepo getDept() {
          return dept;
      }
  
      public void setDept(DepartmentRepo dept) {
          this.dept = dept;
      }
  
  }
  </code></pre>
  
  <p>DepartmentRepo.java</p>
  
  <pre><code>package ir.ac.ut.ieproj.da;
  
  import org.hibernate.HibernateException;
  import org.hibernate.MappingException;
  import org.hibernate.Query;
  import org.hibernate.Session;
  import org.hibernate.Transaction;
  
  import ir.ac.ut.ieproj.model.Department;
  
  public class DepartmentRepo {
  
      private int id;
      private String name;
  
      public Department getDeptbyId(String id) throws MappingException, HibernateException, Exception {
  
          Session session = HibernateUtil.getHibernateSession();
          Transaction tx = session.beginTransaction();
          Query query = session.getNamedQuery("getDeptName").setLong("id", Integer.valueOf(id));
          DepartmentRepo departmentRepo = (DepartmentRepo) query.uniqueResult();
          Department department = new Department();
          department.setName(departmentRepo.getName());
          tx.commit();
          session.close();
  
          return department;
  
      }
  
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
  }
  </code></pre>
  
  <p>I think the problem is with the many-to-one tag in Student.hbm.xml because Department.hbm.xml and the namedQuery within are not causing an error. What am I doing wrong? I'm using mvn package to make a .war file and then deploy it in tomcat 7.</p>