title: No Hibernate session bound to the thread while using multiple transation managers
body: <p>I have created two transaction managers(one for READ requests and another for READ-WRITE requests) and two session factories for the same.</p>
  
  <p>Important snippets are as follows:</p>
  
  <pre><code>&lt;tx:annotation-driven /&gt;
  
  &lt;bean id="txManager"
      class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="SessionFactory" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="txManagerRead"
      class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="SessionFactory" /&gt;
      &lt;qualifier value="READ"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="txManagerWrite"
      class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="SessionFactory1" /&gt;
       &lt;qualifier value="WRITE"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="AbstractSessionFactory"
      class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
      abstract="true"&gt;
      &lt;property name="annotatedClasses"&gt;
          &lt;list&gt;
  .....
  ....
          &lt;/list&gt;
      &lt;/property&gt;
      &lt;property name="exposeTransactionAwareSessionFactory"&gt;
          &lt;value&gt;true&lt;/value&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="SessionFactory"
      class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
      parent="AbstractSessionFactory"&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
  .........
  .........
  &lt;/props&gt;
  &lt;/property&gt;
  &lt;/bean&gt;
  
  
  
  &lt;bean id="SessionFactory1"
      class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
      parent="AbstractSessionFactory"&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
  .........
  .........
  &lt;/props&gt;
  &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I am getting following exception : </p>
  
  <pre><code>Caused by: org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
  
      at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63)
  
      at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574)
  
      at com.amazon.im.dao.hibernate.GenericDAOImpl.getSession(GenericDAOImpl.java:53)
  
      at com.amazon.im.dao.hibernate.CategoryDAOImpl.findAllActiveCategories(CategoryDAOImpl.java:54)
  
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  </code></pre>
  
  <p>Method which calls DAO is as follows: </p>
  
  <pre><code> @Transactional(rollbackFor = { DependencyException.class, ServiceException.class }, readOnly = true, value="READ")
  @Operation("getActiveCategories")
  public GetActiveCategoriesResponse getActiveCategories() throws ServiceException, DependencyException
  { .....
  ......
  ......
  }
  </code></pre>
  
  <p>Can anyone point me to the part I am doing wrong?</p>