title: Hibernate-Unable to load class declared in Hibernate configuration </mapping> entry
body: <p>In Eclipse, I have been building a simple Hibernate+Spring+MySQL+Maven project recently.I am stuck at the stage of database&amp;java connection.When I run the project, it gives the the following error:</p>
  
  <pre><code>Exception in thread "main" org.hibernate.MappingException: Unable to load class [ src/main/java/com.hibernate.data/Person] declared in  Hibernate configuration &lt;mapping/&gt; entry
  at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2279)
  at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2227)
  at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2207)
  at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2160)
  at org.hibernate.cfg.Configuration.configure(Configuration.java:2075)
  at com.test.Main.main(Main.java:17)
  Caused by: java.lang.ClassNotFoundException:src/main/java/com.hibernate.data/Person
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Class.java:260)
  at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:193)
  at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2276)
  ... 5 more
  </code></pre>
  
  <p>The main class:</p>
  
  <pre><code>package com.test;
  
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.Transaction;
  import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
  import org.hibernate.cfg.Configuration;
  
  import com.hibernate.data.Person;
  
  public class Main {
  public static void main(String [] args){
  
      // Create a configuration instance
      Configuration configuration = new Configuration();
      // Provide configuration file
      configuration.configure("hibernate.cfg.xml");
      // Build a SessionFactory
      SessionFactory factory = configuration.buildSessionFactory(new StandardServiceRegistryBuilder().configure().build());
      // Get current session, current session is already associated with Thread
      Session session = factory.getCurrentSession();
      // Begin transaction, if you would like save your instances, your calling of save must be associated with a transaction
      Transaction tx = session.getTransaction();
  
      // Create person
      Person newPerson = new Person();
      newPerson.setFirstName("Peter");
      newPerson.setLastName("Jackson");
      newPerson.setGender("Male");
      newPerson.setAge(30);
      //Save
      session.save(newPerson);
      session.flush();
  
      tx.commit();
      session.close();
  
      /*
      @SuppressWarnings("deprecation")
      SessionFactory sf = new Configuration().configure().buildSessionFactory();
      System.out.println("CFG and hbm files loaded successfully.");
      Session session = sf.openSession();
      session.beginTransaction();
      System.out.println("Transaction began");
      */
  
  }
  }
  </code></pre>
  
  <p>hbm.xml 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 table="Person" lazy="false" name="com.hibernate.data.Person" &gt;
      &lt;id column="PERSON_ID" type="int" name="id" &gt;
          &lt;generator class="increment"/&gt;
      &lt;/id&gt;
          &lt;property name="firstName" column="PERSON_FIRSTNAME" type="string" /&gt;
          &lt;property name="lastName" column="PERSON_LASTNAME" type="string" /&gt;
          &lt;property name="gender" column="PERSON_GENDER" type="string" /&gt;
          &lt;property name="age" column="PERSON_AGE" type="int"  /&gt;
  &lt;/class&gt;
  </code></pre>
  
  <p></p>
  
  <p>hibernate.cfg.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  
  &lt;hibernate-configuration&gt;
  
  &lt;session-factory&gt;
  &lt;!-- Database connection settings --&gt;
  &lt;property name="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
  &lt;property name="connection.url"&gt;jdbc:mysql://localhost:3306/PERSONDB&lt;/property&gt;
  &lt;property name='connection.username'&gt;root&lt;/property&gt;
  &lt;property name='connection.password'&gt;root&lt;/property&gt;
  
  &lt;!-- SQL dialect --&gt;
  &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
  &lt;!-- Specify session context --&gt;
  &lt;property name="hibernate.current_session_context_class"&gt;thread&lt;/property&gt;
  &lt;!-- Show SQL --&gt;
  &lt;property name="show_sql"&gt;true&lt;/property&gt;
  &lt;!-- Referring Mapping File --&gt;
  &lt;mapping resource="domain-classes.hbm.xml"/&gt;
  &lt;mapping class="src/main/java/com.hibernate.data/Person"/&gt;
  &lt;/session-factory&gt;
  
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>Person.java:</p>
  
  <pre><code>package com.hibernate.data;
  
  public class Person {
  private int id;
  private String firstName;
  private String lastName;
  private String gender;
  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 String getGender() {
      return gender;
  }
  public void setGender(String gender) {
      this.gender = gender;
  }
  public int getAge() {
      return age;
  }
  public void setAge(int age) {
      this.age = age;
  }
  }
  </code></pre>
  
  <h2>What is wrong here?</h2>
  
  <p>EDIT:</p>
  
  <p>I modified pom.xml file as maven-exec plugin requires:</p>
  
  <p><img src="https://i.stack.imgur.com/YORZ5.png" alt="enter image description here"></p>
  
  <p>Additionally, final project structure is as follows:</p>
  
  <p><img src="https://i.stack.imgur.com/aDyZr.png" alt="enter image description here">
  but still, it gives the same error.What am I doing wrong?</p>