title: Cannot resolve reference to bean 'sessionFactory'
body: <p>Iam working with spring , hibernate maven project am getting the exception Cannot resolve reference to bean 'sessionFactory'  on dispatcher servlet.xml file.  Below iam adding the three file contents. both dispatcherservlet and application context are in resources folder.
  what is the problem? please help</p>
  
  <p>My error:org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stockBo' defined in class path resource [dispatcher-servlet.xml]: Cannot resolve reference to bean 'stockDao' while setting bean property 'stockDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stockDao' defined in class path resource [dispatcher-servlet.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory' is defined</p>
  
  <p>Dispatcher-servlet.xml file</p>
  
  <pre><code>&lt;!-- Stock Data Access Object --&gt;
  
  &lt;bean id="stockBo" lazy-init="true" class="com.org.rolltickets.stock.bo.impl.StockBoImpl" &gt;
  &lt;property name="stockDao"&gt;
  &lt;ref local="stockDao" /&gt;
  &lt;/property&gt;
  &lt;/bean&gt;
  
  
   &lt;bean id="stockDao" lazy-init="true" class="com.org.rolltickets.stock.dao.impl.StockDaoImpl" &gt;
  &lt;property name="sessionFactory"&gt;
  &lt;ref bean="sessionFactory" /&gt;
  &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Applcaitioncontext.xml </p>
  
  <pre><code>&lt;!-- Hibernate session factory --&gt;
      &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource"&gt;
              &lt;ref bean="dataSource"/&gt;
          &lt;/property&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
  
          &lt;property name="mappingResources"&gt;
              &lt;list&gt;
                  &lt;value&gt;/hibernate/Stock.hbm.xml&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
  
      &lt;/bean&gt;
  </code></pre>
  
  <p>Web.xml file</p>
  
  <pre><code>&lt;context-param&gt;
  &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
  &lt;param-value&gt;classpath:ApplicationContext.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;listener&gt;
  &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  &lt;servlet&gt;
  &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
  &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
  &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;session-config&gt;
  &lt;session-timeout&gt;30&lt;/session-timeout&gt;
  &lt;/session-config&gt;
  </code></pre>