title: SqlSessionFactory must be using a SpringManagedTransactionFactory in order to use Spring transaction synchronization
body: <p>I've got an app running on Tomcat 7, using Spring, Mybatis, and .. Mybatis-spring.</p>
  
  <p>Here's the setup for the DB and transactions in servlet-context.xml:</p>
  
  <pre><code>&lt;jee:jndi-lookup id="dataSource" jndi-name="jdbc/MyDS" /&gt;
  &lt;!-- enable the configuration of transactional behavior based on annotations --&gt;
  &lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;
  &lt;bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
        &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  &lt;bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"&gt;
        &lt;property name="dataSource" ref="dataSource" /&gt;
        &lt;property name="mapperLocations" value="classpath*:maps/*.xml" /&gt;
        &lt;property name="transactionFactory"&gt;
          &lt;bean class="org.apache.ibatis.transaction.managed.ManagedTransactionFactory" /&gt;
        &lt;/property&gt;  
  &lt;/bean&gt;
  &lt;mybatis:scan base-package="com.domain.dao.mappers" /&gt;
  &lt;bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate"&gt;
  &lt;constructor-arg index="0" ref="sqlSessionFactory" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>The error I'm getting when I run a method that uses the SqlSession is the following:</p>
  
  <pre><code>org.springframework.dao.TransientDataAccessResourceException: SqlSessionFactory must be using a SpringManagedTransactionFactory in order to use Spring transaction synchronization
      at org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:136)
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>My goal, really, is just to use transactions with this setup. I don't think I necessarilly need JTA. But if that's easy enough to setup on Tomcat, I'm willing to take a swing at it.</p>