title: Correctly setting up JTA Transaction Manager in Tomcat Server with Atomikos
body: <p>How would I setup container-managed datasources and embedded Active MQ resources to <code>JTATransactionManager</code> for global Transactions?<br/></p>
  <p>I am using Tomcat 6 and installed Atomikos in it to support JTA. I use Hibernate for ORM. Here is my configuration:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;bean id=&quot;AtomikosTransactionManager&quot;  
        class=&quot;com.atomikos.icatch.jta.UserTransactionManager&quot;  
      init-method=&quot;init&quot; destroy-method=&quot;close&quot;&gt; 
     &lt;!--  when close is called, should we force  
           transactions to terminate or not?  --&gt; 
     &lt;property name=&quot;forceShutdown&quot; value=&quot;false&quot; /&gt; 
  &lt;/bean&gt; 
  
  &lt;bean id=&quot;AtomikosUserTransaction&quot;  
     class=&quot;com.atomikos.icatch.jta.UserTransactionImp&quot;&gt;      
     &lt;property name=&quot;transactionTimeout&quot; value=&quot;300&quot; /&gt; 
  &lt;/bean&gt;
  
  &lt;jee:jndi-lookup expected-type=&quot;javax.sql.DataSource&quot; id=&quot;dataSource&quot; jndi-name=&quot;jdbc/EDITSOLUTIONS&quot;/&gt;
  
  &lt;bean id=&quot;sessionFactory&quot; class=&quot;org.springframework.orm.hibernate.LocalSessionFactoryBean&quot;&gt;
      &lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot;/&gt;
      &lt;property name=&quot;mappingResources&quot;/&gt;
      &lt;list&gt;
          &lt;value&gt;../../src/editsolutions.hibernate.cfg.xml&lt;/value&gt;
      &lt;/list&gt;
      &lt;property name=&quot;hibernateProperties&quot;&gt;
          &lt;value&gt;
              hibernate.dialect=${hibernate.dialect}
          &lt;/value&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id=&quot;activemq&quot; class=&quot;org.apache.activemq.camel.component.ActiveMQComponent&quot;&gt;
      &lt;property name=&quot;connectionFactory&quot;&gt;
          &lt;bean class=&quot;org.apache.activemq.ActiveMQConnectionFactory&quot;&gt;
              &lt;property name=&quot;brokerURL&quot; value=&quot;failover://tcp://localhost:61616&quot;/&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id=&quot;jmsConnectionFactory&quot;class=&quot;org.apache.activemq.ActiveMQConnectionFactory&quot;&gt;
      &lt;property name=&quot;brokerURL&quot; value=&quot;failover://tcp://localhost:61616&quot;/&gt;
  &lt;/bean&gt;
  
  &lt;bean name=&quot;txManager&quot; class=&quot;org.springframework.transaction.jta.JtaTransactionManager&quot;&gt;
      &lt;property name=&quot;transactionManager&quot; ref=&quot;AtomikosTransactionManager&quot; /&gt; 
      &lt;property name=&quot;userTransaction&quot; ref=&quot;AtomikosUserTransaction&quot; /&gt;
  &lt;/bean&gt;
  </code></pre>
  <p>Spring documentation says that JTA Transaction Manager need not be told about resources. That's what I have done. <br/></p>
  <br>
  <h3> I have the following outstanding questions: </h3>
  <ol>
  <li>I am not sure whether <code>Atomikos</code> is integrated properly or not?</li>
  <li>Is it OK to get the datasource from <code>&lt;jee:jndi-lookup&gt;</code>?</li>
  <li>Is Hiberante configuration correct with respect to <code>JTATransactionManager</code>?</li>
  <li>As it is embedded in JVM not managed by container, would JTATransactionManager be able to recognize ActimeMQ ?</li>
  </ol>