title: Spring + JPA/Hibernate + ActiveMQ with XA/JTA in un-managed container. Not seeing errors, but not seeing data being committed to database
body: <p>I'm in the process of adding JMS capabilities (via ActiveMQ) to an existing Spring/Hibernate web application. Consequently, I'm wanting to add XA/JTA capabilities to this app such that I can manage transactions (with Spring) which span both the data store and the message broker.</p>
  
  <p>I've been successful with the ActiveMQ integration, but, I'm running into problems with incorporating XA/JTA into the application. Specifically, no data is being inserted/updated into underlying database (though, I see no errors/exceptions during the transaction).</p>
  
  <p>Details: Spring 3.1.2.RELEASE, Hibernate 3.6.10.Final, ActiveMQ 5.6.0</p>
  
  <p>I'm using Spring Data JPA for writing my DAO interfaces and they, in turn, pick up my LocalContainerEntityManagerFactoryBean to do their CRUD work.</p>
  
  <p>I've tried with both Atomikos (5.6.0) and Bitronix (2.1.3) XA/JTA implementations. Each results in same behavior (no data being written to underlying database tables).</p>
  
  <p>I have a lot of logging and can certainly provide log excerpts if desired. And, configuration details as well. Of particular note in the logs, Spring seems to indicate that JTA transaction is (trying to?) commit. Given the lack of data written to underlying db, though, it's not clear if it actually completes the commit (again, though, I see no errors indicating that it did not). Also, it's worth noting that this particular transaction - populateSampleData - involves just the database resource (no message broker involvement at all).</p>
  
  <pre><code>2012-08-14 13:16:09,770 DEBUG [org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] - Adding transactional method 'populateSampleData' with attribute: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
  2012-08-14 13:16:09,772 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:09,776 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Creating new transaction with name [com.teg.saamweb.service.SaamWebServiceTransactional.populateSampleData]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
  2012-08-14 13:16:09,811 DEBUG [org.springframework.orm.jpa.EntityManagerFactoryUtils] - Opening JPA EntityManager
  2012-08-14 13:16:09,812 DEBUG [org.springframework.orm.jpa.EntityManagerFactoryUtils] - Registering transaction synchronization for JPA EntityManager
  2012-08-14 13:16:09,898 DEBUG [org.springframework.data.repository.core.support.TransactionalRepositoryProxyPostProcessor$CustomAnnotationTransactionAttributeSource] - Adding transactional method 'save' with attribute: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
  2012-08-14 13:16:09,899 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:09,899 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Participating in existing transaction
  2012-08-14 13:16:09,964 DEBUG [org.springframework.data.repository.core.support.TransactionalRepositoryProxyPostProcessor$CustomAnnotationTransactionAttributeSource] - Adding transactional method 'save' with attribute: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
  2012-08-14 13:16:09,964 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:09,964 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Participating in existing transaction
  2012-08-14 13:16:09,982 DEBUG [org.springframework.data.repository.core.support.TransactionalRepositoryProxyPostProcessor$CustomAnnotationTransactionAttributeSource] - Adding transactional method 'save' with attribute: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
  2012-08-14 13:16:09,982 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:09,983 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Participating in existing transaction
  2012-08-14 13:16:09,992 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:09,992 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Participating in existing transaction
  2012-08-14 13:16:09,996 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:09,996 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Participating in existing transaction
  2012-08-14 13:16:10,000 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:10,000 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Participating in existing transaction
  2012-08-14 13:16:10,003 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:10,003 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Participating in existing transaction
  2012-08-14 13:16:10,007 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:10,007 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Participating in existing transaction
  2012-08-14 13:16:10,011 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:10,011 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Participating in existing transaction
  2012-08-14 13:16:10,014 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:10,014 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Participating in existing transaction
  2012-08-14 13:16:10,017 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:10,017 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Participating in existing transaction
  2012-08-14 13:16:10,020 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:10,020 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Participating in existing transaction
  2012-08-14 13:16:10,023 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:10,023 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Participating in existing transaction
  2012-08-14 13:16:10,026 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:10,026 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Participating in existing transaction
  2012-08-14 13:16:10,030 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:10,030 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Participating in existing transaction
  2012-08-14 13:16:10,033 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:10,033 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Participating in existing transaction
  2012-08-14 13:16:10,036 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'transactionManager'
  2012-08-14 13:16:10,036 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Participating in existing transaction
  2012-08-14 13:16:10,038 DEBUG [org.springframework.orm.jpa.EntityManagerFactoryUtils] - Closing JPA EntityManager
  2012-08-14 13:16:10,039 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] - Initiating transaction commit
  </code></pre>
  
  <p>I'm hoping to find someone who has successfully set up such an Spring XA/JTA application for transaction management who can provide some suggestions as to what I might be doing incorrectly (or missing). I've basically followed the prescription in <a href="http://blog.springsource.com/2011/08/15/configuring-spring-and-jta-without-full-java-ee/" rel="nofollow">this article</a> (with a bit of additional info gathered from the Atomikos web site in the Atomikos case).</p>
  
  <p>Thanks for any enlightenment you can provide.</p>
  
  <p><strong>Update:</strong> I resolved my issue. The problem was that I was not using a persistence.xml file (but rather configuring the persistence-unit programmatically when setting up the LocalContainerEntityManagerFactoryBean using the setPackagesToScan method). While the persistence-unit was indeed loading my @Entity classes properly, due to the absence of the persistence.xml file (specifically, the absence of the transaction-type attribute of the persistence-unit element) the transaction-type was being defaulted to RESOURCE_LOCAL (which is the default for non-Java EE containers). I'm now explicitly providing a persistence.xml file and explicitly setting transaction-type="JTA".</p>