title: SessionFactory is null
body: <p>I'm using Spring with Hibernate and originally set up my project <a href="http://docs.jboss.org/hibernate/orm/3.6/reference/en-US/html/session-configuration.html#configuration-xmlconfig" rel="nofollow">with a hibernate xml config</a>, which resulted in performance issues and seemed like it was the wrong way to do it. I'm now trying to inject my SessionFactory, starting with 1 dao, but get a null pointer exception where sessionFactory.getCurrentSession() is called. I think my code looks like the examples I've seen. I'm stumped. I also tried not using resource and injecting the sessionFactory into the dao in the application context instead. Same result.</p>
  
  <p>ApplicationContext.xml</p>
  
  <pre><code> &lt;context:component-scan base-package="path.to.base"&gt;
      &lt;context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/&gt;
  &lt;/context:component-scan&gt;
  
  &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="mappingDirectoryLocations"&gt;
         &lt;list&gt;
             &lt;value&gt;classpath*:/path/to/mapping/files&lt;/value&gt;
         &lt;/list&gt;
      &lt;/property&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="dialect"&gt;org.hibernate.dialect.Oracle10gDialect&lt;/prop&gt;
               &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  &lt;bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
  &lt;/bean&gt;
  
  &lt;tx:annotation-driven/&gt;
  
  &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
      &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /&gt;
      &lt;property name="url" value="${jdbc.url}" /&gt;
      &lt;property name="username" value="${jdbc.username}" /&gt;
      &lt;property name="password" value="${jdbc.password}" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>myDAO</p>
  
  <pre><code>@Repository
  public class myDAO {
  private SessionFactory sessionFactory;
  
  public SessionFactory getSessionFactory(){
      return sessionFactory;
  }
  
  @Resource(name="sessionFactory")
  public void setSessionFactory(SessionFactory sessionFactory) {
      this.sessionFactory = sessionFactory;
  }
  
  public myDAO() {
  
  }
  
  @SuppressWarnings("unchecked")
  @Transactional(readOnly=true)
  public List&lt;Things&gt; getAllThings() {
      return sessionFactory.getCurrentSession().createCriteria(EvalMasterEvaluationType.class)
              .add(Restrictions.eq("active", "Y")).addOrder(Order.desc("createDtTm")).list();
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Spring 3.2.1, Hibernate 3.6.10</p>