title: org.hibernate.HibernateException: No Session found for current thread
body: <p>I'm getting the above exception with Spring3 and Hibernte4</p>
  
  <p>The following is my bean xml file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:context="http://www.springframework.org/schema/context"
     xmlns:tx="http://www.springframework.org/schema/tx"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="
      http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context-3.0.xsd
      http://www.springframework.org/schema/tx
      http://www.springframework.org/schema/tx/spring-tx-3.1.xsd"&gt;
  
     &lt;context:annotation-config/&gt;
  
  
     &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
        &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"/&gt;
        &lt;property name="url" value="jdbc:mysql://localhost:3306/GHS"/&gt;
        &lt;property name="username" value="root"/&gt;
        &lt;property name="password" value="newpwd"/&gt;
    &lt;/bean&gt;
  
    &lt;bean id="sessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource"/&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="dialect"&gt;org.hibernate.dialect.MySQL5Dialect&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
      &lt;property name="packagesToScan"&gt;
          &lt;list&gt;
              &lt;value&gt;com.example.ghs.model.timetable&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
    &lt;/bean&gt;
  
     &lt;bean id="baseDAO"
        class="com.example.ghs.dao.BaseDAOImpl"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>My BaseDAO class looks like this</p>
  
  <pre><code>public class BaseDAOImpl implements BaseDAO{
  private SessionFactory sessionFactory;
  
   @Autowired
   public BaseDAOImpl(SessionFactory sessionFactory){
       this.sessionFactory = sessionFactory;
   }
  
   @Override
   public Session getCurrentSession(){
       return sessionFactory.getCurrentSession();
   }
  }
  </code></pre>
  
  <p>The following code throws the exception in the title</p>
  
  <pre><code>public class Main {
   public static void main(String[] args){
      ClassPathXmlApplicationContext context =
              new ClassPathXmlApplicationContext("dao-beans.xml");
      BaseDAO bd = (BaseDAO) context.getBean("baseDAO");
      bd.getCurrentSession();
   }
  }
  </code></pre>
  
  <p>Does anyone have an idea about how to solve this problem?</p>