title: Location of hibernate.cfg.xml in project?
body: <p>I created a project with following structure:</p>
  
  <p><img src="https://i.stack.imgur.com/p723b.jpg" alt="enter image description here"></p>
  
  <p>HibernateUtil:</p>
  
  <pre><code>public class HibernateUtil {
  
      private static final SessionFactory sessionFactory = buildSessionFactory();
  
      private static SessionFactory buildSessionFactory() {
          try {
              // Create the SessionFactory from hibernate.cfg.xml
              Configuration  configuration = new Configuration().configure( "C:\\Users\\Nikolay_Tkachev\\workspace\\hiberTest\\src\\logic\\hibernate.cfg.xml");
              return new Configuration().configure().buildSessionFactory();
          } catch (Throwable ex) {
              // Make sure you log the exception, as it might be swallowed
              System.err.println("Initial SessionFactory creation failed." + ex);
              throw new ExceptionInInitializerError(ex);
          }
      }
  
      public static SessionFactory getSessionFactory() {
          return sessionFactory;
      }
  
      public static void shutdown() {
          // Close caches and connection pools
          getSessionFactory().close();
      }
  
  }
  </code></pre>
  
  <p>at line</p>
  
  <pre><code>Configuration  configuration = new Configuration().configure( "C:\\Users\\Nikolay_Tkachev\\workspace\\hiberTest\\src\\logic\\hibernate.cfg.xml");
  </code></pre>
  
  <p>I have error</p>
  
  <blockquote>
    <p>Initial SessionFactory creation
    failed.org.hibernate.HibernateException:
    C:\Users\Nikolay_Tkachev\workspace\hiberTest\src\logic\hibernate.cfg.xml
    not found Exception in thread "main"
    java.lang.ExceptionInInitializerError     at
    logic.HibernateUtil.buildSessionFactory(HibernateUtil.java:19)    at
    logic.HibernateUtil.(HibernateUtil.java:9)    at
    logic.Main.main(Main.java:12) Caused by:
    org.hibernate.HibernateException:
    C:\Users\Nikolay_Tkachev\workspace\hiberTest\src\logic\hibernate.cfg.xml
    not found     at
    org.hibernate.internal.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:173)
      at
    org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1947)
      at org.hibernate.cfg.Configuration.configure(Configuration.java:1928)
      at logic.HibernateUtil.buildSessionFactory(HibernateUtil.java:14)
      ... 2 more</p>
  </blockquote>
  
  <p>What is the reason for the error and how do I fix it?</p>