title: "Could not locate cfg.xml resource [hibernate.cfg.xml]" error
body: <p>When I run my <code>createStudentDemo</code> class I get the following error:</p>
  
  <pre><code>INFO: HHH000412: Hibernate Core {5.4.11.Final}
  
  Exception in thread "main"
  org.hibernate.internal.util.config.ConfigurationException: Could not
  locate cfg.xml resource [hibernate.cfg.xml] at
  org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:53) at
  org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:215) at org.hibernate.cfg.Configuration.configure(Configuration.java:258)
  at org.hibernate.cfg.Configuration.configure(Configuration.java:244)
  at
  com.luv2code.hibernate.demo.CreateStudentDemo.main(CreateStudentDemo.java:15)
  </code></pre>
  
  <p>I don't understand why I have this error.</p>
  
  <p>Here is the code of my <code>createStudentDemo</code> class:</p>
  
  <pre class="lang-java prettyprint-override"><code>package com.luv2code.hibernate.demo;
  
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.cfg.Configuration;
  import com.luv2code.hibernate.demo.entity.Student;
  
  public class CreateStudentDemo {
  
      public static void main(String[] args) {
          // create session factory
  
          SessionFactory factory= new Configuration()
                                      .configure("hibernate.cfg.xml")
                                      .addAnnotatedClass(Student.class)
                                      .buildSessionFactory();
  
          // create session
          Session session = factory.getCurrentSession();
  
          try {
              //create a student object
              System.out.println("creating new student object");
              Student tempStudent = new Student("Paul", "Wall", "paul@luv2code.com");
  
              //start a transaction
              session.beginTransaction();
  
              // save the student object
              System.out.println("Saving the student...");
              session.save(tempStudent);
  
              //commit transaction
              session.getTransaction().commit();
                  System.out.println("Done !");
          }
          finally {
              factory.close();
          }
      }
  }
  </code></pre>
  
  <p>and here is the code for my class student:</p>
  
  <pre class="lang-java prettyprint-override"><code>package com.luv2code.hibernate.demo.entity;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  @Entity
  @Table(name="student")
  public class Student {
  
      public Student() {
      }
      @Id
      @Column(name="id")
      private int id;
  
      @Column(name="first_name")
      private String firstName;
  
      @Column(name="last_name")
      private String lastName;
  
      @Column(name="email")
      private String email;
  
      public Student(String firstName, String lastName, String email) {
  
          this.firstName = firstName;
          this.lastName = lastName;
          this.email = email;
      }
  
      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 getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      @Override
      public String toString() {
          return "Student [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", email=" + email + "]";
      }
  }
  </code></pre>
  
  <p>and here is the code of my <code>hibernate.cfg.xml</code> file:</p>
  
  <pre class="lang-xml prettyprint-override"><code>    &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;!-- JDBC Database connection settings --&gt;
              &lt;property name="connection.driver_class"&gt;com.mysql.cj.jdbc.Driver&lt;/property&gt;
              &lt;property name="connection.url"&gt;jdbc:mysql://localhost:3306/hb_student_tracker?useSSL=false&amp;amp;serverTimezone=UTC&lt;/property&gt;
              &lt;property name="connection.username"&gt;hbstudent&lt;/property&gt;
              &lt;property name="connection.password"&gt;hbstudent&lt;/property&gt;
  
              &lt;!-- JDBC connection pool settings ... using built-in test pool --&gt;
              &lt;property name="connection.pool_size"&gt;1&lt;/property&gt;
  
              &lt;!-- Select our SQL dialect --&gt;
              &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
  
              &lt;!-- Echo the SQL to stdout --&gt;
              &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
              &lt;!-- Set the current session context --&gt;
              &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt;
  
          &lt;/session-factory&gt;
  
      &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>and here is the location of my files:</p>
  
  <p><a href="https://i.stack.imgur.com/aK0Q7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aK0Q7.png" alt="location files"></a></p>
  
  <p>Can someone help me please?</p>