title: TransactionException: Transaction not successfully started
body: <p>I have following dao:</p>
  
  <pre><code>@Repository("userDao")
  public class UserDaoImpl implements UserDao {
  
      @Autowired
      private SessionFactory sessionFactory;
  
      @Transactional
      public void add(User user) {
          Session session = sessionFactory.getCurrentSession();
          session.save(user);
          session.getTransaction().commit();
      }
  }
  </code></pre>
  
  <p>it is invokes from</p>
  
  <pre><code>@Controller
  public class HomeController {    
  
      @Autowired
      private UserDao userDao;
  
  
      @RequestMapping(value = "/test")
      public ModelAndView test() {
          User user = new User();
          user.setName("34r");
  
          userDao.add(user);
  
          ModelAndView model = new ModelAndView("home");
          model.addObject("userList", null);
          return model;
  
      }
  
  }
  </code></pre>
  
  <p>in browser I try to access to this link </p>
  
  <p>And finally I get following stacktrace:</p>
  
  <pre><code>SEVERE: Servlet.service() for servlet [appServlet] in context with path [/SpringMvcHibernateXML] threw exception [Request processing failed; nested exception is org.springframework.transaction.TransactionSystemException: Could not commit Hibernate transaction; nested exception is org.hibernate.TransactionException: Transaction not successfully started] with root cause
  org.hibernate.TransactionException: Transaction not successfully started
      at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:172)
  </code></pre>
  
  <p>I have following configuration:</p>
  
  <pre><code>&lt;bean id="sessionFactory"
          class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="configLocation" value="classpath:hibernate.cfg.xml" /&gt;
      &lt;/bean&gt;
  
      &lt;tx:annotation-driven /&gt;
      &lt;bean id="transactionManager"
          class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>How to fix this problem?</p>