title: Cannot load configuration from /hibernate.cfg.xml
body: <p>I have a web project where I am using Hibernate. Structure of project is:</p>
  
  <pre><code>src
  |
  |--java
  |    |--com.rusakov...
  |
  |--resources
  |    |--hibernate.cfg.xml
  |
  |--webapp
       |--WEB-INF
  </code></pre>
  
  <p>My hibernate.cfg.xml looks like:</p>
  
  <pre><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;!-- Database connection settings --&gt;
      &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
      &lt;property name="connection.url"&gt;jdbc:mysql://localhost:3306/computersdb&lt;/property&gt;
      &lt;property name="connection.username"&gt;root&lt;/property&gt;
      &lt;property name="connection.password"&gt;34902&lt;/property&gt;
  
      &lt;!-- JDBC connection pool (use the built-in) --&gt;
      &lt;property name="connection.pool_size"&gt;1&lt;/property&gt;
  
      &lt;!-- SQL dialect --&gt;
      &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
  
      &lt;!-- Echo all executed SQL to stdout --&gt;
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
      &lt;!-- Drop and re-create the database schema on startup --&gt;
      &lt;property name="hbm2ddl.auto"&gt;update&lt;/property&gt;
  
      &lt;mapping package="com.rusakov.entities"/&gt;
    &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>My class for initialization of <code>SessionFactory</code>:</p>
  
  <pre><code>public class HibernateUtil {
      private static SessionFactory sessionFactory = null;
  
      public static SessionFactory getSessionFactory() {
          if (sessionFactory == null) {
              try {
                  Configuration configuration = new Configuration();
                  configuration.configure();
                  ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder()
                          .applySettings(configuration.getProperties());
                  sessionFactory = configuration
                          .buildSessionFactory(serviceRegistryBuilder.buildServiceRegistry());
              } catch (HibernateException e) {
                  e.printStackTrace();
              }
          }
          return sessionFactory;
      }
  }
  </code></pre>
  
  <p><code>Entity</code> class:</p>
  
  <pre><code>public class UserEnt {
      private int id;
      private String login;
      private String password;
      private String name;
      private String surname;
  
      public UserEnt() {};
  
      //** setters and getters **//
  }
  </code></pre>
  
  <p>When I am trying to save <code>User</code> object to database I am getting this:</p>
  
  <pre><code>INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
  org.hibernate.HibernateException: /hibernate.cfg.xml not found
  </code></pre>
  
  <p>My class where I call <code>SessionFactory</code></p>
  
  <pre><code>package com.rusakov.util;
  
  import com.rusakov.entities.*;
  
  import org.hibernate.Session;
  
  public class test {
      public static void main(String[] args) {
          UserEnt user = new UserEnt();
          user.setName("test");
          user.setSurname("test");
          user.setLogin("test");
          user.setPassword("test");
          user.setRole("test");
          Session session = HibernateUtil.getSessionFactory().openSession();
          session.beginTransaction();
          session.save(user);
          session.getTransaction().commit();
      }
  }
  </code></pre>
  
  <p>What I am doing wrong?</p>