title: hibernate.cfg.xml not found in spring mv3 application
body: <p>I am using spring mvc3 and hibernate3. In my application i have a requirement to use a servlet. 
  In that servelet I have to call my DAO Layer. but when I am using following code in my servlet. </p>
  
  <pre><code>Session session = HibernateUtil.getSessionFactory().openSession();
  public class HibernateUtil {
      private static final SessionFactory sessionFactory;
      static {
          try {
              sessionFactory = new Configuration().configure()
                      .buildSessionFactory();
          } catch (Throwable ex) {
              System.err.println("Initial SessionFactory creation failed." + ex);
              throw new ExceptionInInitializerError(ex);
          }
      }
  
      public static SessionFactory getSessionFactory() {
          return sessionFactory;
      }
  }
  </code></pre>
  
  <p>I am getting error org.hibernate.HibernateException: hibernate.cfg.xml not found.</p>
  
  <p>Currently my xml file is in WEB-INF folder along with other configuration file.</p>
  
  <p>All solutions are saying I need to keep it in src folder so automatically it will be fetched at runtime. but I am using spring mvc here.
  So i am little bit confuse please help me how to solve it.</p>
  
  <p>all other places where I am using controller its working fine.</p>
  
  <p><img src="https://i.stack.imgur.com/Gwk3j.png" alt="enter image description here"></p>
  
  <p>I am using following entry in carpool-servlet.xml</p>
  
  <p></p>
  
  <p>following is my carpool-hibernate.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans  xmlns="http://www.springframework.org/schema/beans" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:p="http://www.springframework.org/schema/p" 
          xmlns:tx="http://www.springframework.org/schema/tx"
          xmlns:context="http://www.springframework.org/schema/context"
          xsi:schemaLocation="
              http://www.springframework.org/schema/beans 
              http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
              http://www.springframework.org/schema/tx 
              http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
              http://www.springframework.org/schema/context
              http://www.springframework.org/schema/context/spring-context-3.0.xsd
              "&gt;
  
      &lt;context:property-placeholder location="/WEB-INF/dbproperties.properties" /&gt;
  
      &lt;!-- Enable annotation style of managing transactions --&gt;
      &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;   
  
      &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
                   p:dataSource-ref="dataSource"
                   p:configLocation="${hibernate.config}"
                   p:packagesToScan="store.custom.controllers"&gt;
  
                  &lt;property name="annotatedClasses"&gt;
          &lt;list&gt;
              &lt;value&gt;common.domain.Ride&lt;/value&gt;
              &lt;value&gt;common.businessclass.PostAdRR&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
                   &lt;/bean&gt;
  
      &lt;!-- Declare a datasource that has pooling capabilities--&gt;   
      &lt;bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
                  destroy-method="close"
                  p:driverClass="${jdbc.driverClassName}"
                  p:jdbcUrl="${jdbc.url}"
                  p:user="${jdbc.username}"
                  p:password="${jdbc.password}"
                  p:acquireIncrement="5"
                  p:idleConnectionTestPeriod="60"
                  p:maxPoolSize="100"
                  p:maxStatements="50"
                  p:minPoolSize="10" /&gt;
  
      &lt;!-- Declare a transaction manager--&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" 
                  p:sessionFactory-ref="sessionFactory" /&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>following is my hibernate.cfg.xml</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://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  
  
  &lt;hibernate-configuration&gt;
  
    &lt;session-factory&gt;
      &lt;!-- We're using MySQL database so the dialect needs to MySQL as well--&gt;
      &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5InnoDBDialect&lt;/property&gt;
      &lt;!-- Enable this to see the SQL statements in the logs--&gt;
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
      &lt;!-- This will drop our existing database and re-create a new one.
              Existing data will be deleted! --&gt;
  &lt;!-- &lt;property name="hbm2ddl.auto"&gt;create&lt;/property&gt;--&gt;
    &lt;/session-factory&gt;
  
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p><strong>now how can I set my hibernate config.xml</strong>
  Please help</p>