title: Distributed transactions, Transaction no longer active
body: <p>we are thinking about making our transactions distributed. We implemented a small project as a tester to make sure it could fit in other projects.</p>
  
  <p>At first we set the configuration via annotations and java classes and it worked perfectly but we would like to try an .XML based configuration to avoid the creation of too many config classes.</p>
  
  <p>We are testing with JUnit, not in a proper web app deployed in a server yet, and even it seems to work fine while loading entity managers, transaction configuration and injecting @Services we get the following error when calling methods in the @Repository:</p>
  
  <pre><code>11:50:17.401 [main] DEBUG c.atomikos.icatch.imp.CoordinatorImp - Coordinator 172.18.3.125.tm0000100096 entering state: ACTIVE
  11:50:17.401 [main] INFO  c.a.i.imp.CompositeTransactionImp - setRollbackOnly() called for transaction 172.18.3.125.tm0000100096
  11:50:17.401 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactoryA'
  11:50:17.401 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactoryB'
  11:50:17.401 [main] DEBUG o.s.t.jta.JtaTransactionManager - Participating transaction failed - marking existing transaction as rollback-only
  11:50:17.401 [main] DEBUG o.s.t.jta.JtaTransactionManager - Setting JTA transaction rollback-only
  11:50:17.401 [main] DEBUG c.a.i.imp.BaseTransactionManager - getCompositeTransaction()  returning instance with id 172.18.3.125.tm0000100096
  11:50:17.401 [main] DEBUG c.a.i.imp.BaseTransactionManager - getCompositeTransaction()  returning instance with id 172.18.3.125.tm0000100096
  11:50:17.401 [main] DEBUG c.atomikos.icatch.imp.CoordinatorImp - Coordinator 172.18.3.125.tm0000100096 entering state: ACTIVE
  11:50:17.401 [main] INFO  c.a.i.imp.CompositeTransactionImp - setRollbackOnly() called for transaction 172.18.3.125.tm0000100096
  java.lang.NullPointerException
      at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStatus(JtaStatusHelper.java:76)
      at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.isActive(JtaStatusHelper.java:118)
      at org.hibernate.engine.transaction.internal.jta.CMTTransaction.join(CMTTransaction.java:149)
      at org.hibernate.jpa.spi.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1602)
      at org.hibernate.jpa.spi.AbstractEntityManagerImpl.postInit(AbstractEntityManagerImpl.java:210)
      at org.hibernate.jpa.internal.EntityManagerImpl.&lt;init&gt;(EntityManagerImpl.java:91)
      at org.hibernate.jpa.internal.EntityManagerFactoryImpl.internalCreateEntityManager(EntityManagerFactoryImpl.java:345)
      at org.hibernate.jpa.internal.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:313)
      at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.invokeProxyMethod(AbstractEntityManagerFactoryBean.java:388)
      at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean$ManagedEntityManagerFactoryInvocationHandler.invoke(AbstractEntityManagerFactoryBean.java:541)
      at com.sun.proxy.$Proxy24.createEntityManager(Unknown Source)
      at org.springframework.orm.jpa.EntityManagerFactoryUtils.doGetTransactionalEntityManager(EntityManagerFactoryUtils.java:282)
      at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:254)
      at com.sun.proxy.$Proxy36.merge(Unknown Source)
      at org.springframework.data.jpa.repository.support.SimpleJpaRepository.save(SimpleJpaRepository.java:410)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:416)
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:401)
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:373)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
      at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodIntercceptor.invoke(CrudMethodMetadataPostProcessor.java:122)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
      at com.sun.proxy.$Proxy38.save(Unknown Source)
      at demo.service.StoreServiceImpl.store(StoreServiceImpl.java:26)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
      at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
      at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
      at com.sun.proxy.$Proxy41.store(Unknown Source)
      at demo.EmployeeRepositoryTest.saveBoth(EmployeeRepositoryTest.java:77)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:73)
      at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
      at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:73)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:224)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:83)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:68)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:163)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  11:50:17.411 [main] DEBUG o.s.t.jta.JtaTransactionManager - Initiating transaction rollback
  11:50:17.411 [main] DEBUG c.a.i.imp.BaseTransactionManager - getCompositeTransaction()  returning instance with id 172.18.3.125.tm0000100096
  11:50:17.411 [main] DEBUG c.a.i.imp.BaseTransactionManager - getCompositeTransaction()  returning instance with id 172.18.3.125.tm0000100096
  11:50:17.411 [main] DEBUG c.atomikos.icatch.imp.CoordinatorImp - Coordinator 172.18.3.125.tm0000100096 entering state: ABORTING
  11:50:17.411 [main] DEBUG c.atomikos.icatch.imp.CoordinatorImp - Coordinator 172.18.3.125.tm0000100096 entering state: TERMINATED
  11:50:17.411 [main] DEBUG c.atomikos.icatch.imp.CoordinatorImp - Coordinator 172.18.3.125.tm0000100096 : stopping timer...
  11:50:17.411 [main] DEBUG c.atomikos.icatch.imp.CoordinatorImp - Coordinator 172.18.3.125.tm0000100096 : disposing statehandler TERMINATED...
  11:50:17.411 [main] DEBUG c.atomikos.icatch.imp.CoordinatorImp - Coordinator 172.18.3.125.tm0000100096 : disposed.
  11:50:17.411 [main] DEBUG c.a.i.imp.CompositeTransactionImp - Ignoring error during event callback
  java.lang.IllegalStateException: Transaction no longer active
      at com.atomikos.icatch.imp.TxTerminatedStateHandler.rollbackWithStateCheck(TxTerminatedStateHandler.java:106) ~[transactions-3.9.3.jar:na]
      at com.atomikos.icatch.imp.CompositeTransactionImp.doRollback(CompositeTransactionImp.java:237) [transactions-3.9.3.jar:na]
      at com.atomikos.icatch.imp.CompositeTerminatorImp.rollback(CompositeTerminatorImp.java:123) [transactions-3.9.3.jar:na]
      at com.atomikos.icatch.imp.CompositeTransactionImp.rollback(CompositeTransactionImp.java:346) [transactions-3.9.3.jar:na]
      at com.atomikos.icatch.imp.CompositeTransactionImp.entered(CompositeTransactionImp.java:373) [transactions-3.9.3.jar:na]
      at com.atomikos.finitestates.FSMImp.notifyListeners(FSMImp.java:188) [atomikos-util-3.9.3.jar:na]
      at com.atomikos.finitestates.FSMImp.setState(FSMImp.java:279) [atomikos-util-3.9.3.jar:na]
      at com.atomikos.icatch.imp.CoordinatorImp.setState(CoordinatorImp.java:416) [transactions-3.9.3.jar:na]
      at com.atomikos.icatch.imp.CoordinatorImp.setStateHandler(CoordinatorImp.java:273) [transactions-3.9.3.jar:na]
      at com.atomikos.icatch.imp.CoordinatorStateHandler.rollbackFromWithinCallback(CoordinatorStateHandler.java:769) [transactions-3.9.3.jar:na]
      at com.atomikos.icatch.imp.ActiveStateHandler$7.doRollback(ActiveStateHandler.java:319) [transactions-3.9.3.jar:na]
      at com.atomikos.icatch.imp.CoordinatorStateHandler.rollbackWithAfterCompletionNotification(CoordinatorStateHandler.java:832) [transactions-3.9.3.jar:na]
      at com.atomikos.icatch.imp.ActiveStateHandler.rollbackWithAfterCompletionNotification(ActiveStateHandler.java:49) [transactions-3.9.3.jar:na]
      at com.atomikos.icatch.imp.ActiveStateHandler.rollback(ActiveStateHandler.java:314) [transactions-3.9.3.jar:na]
      at com.atomikos.icatch.imp.CoordinatorImp.rollback(CoordinatorImp.java:741) [transactions-3.9.3.jar:na]
      at com.atomikos.icatch.imp.TransactionStateHandler.rollback(TransactionStateHandler.java:185) [transactions-3.9.3.jar:na]
      at com.atomikos.icatch.imp.TransactionStateHandler.rollbackWithStateCheck(TransactionStateHandler.java:203) [transactions-3.9.3.jar:na]
      at com.atomikos.icatch.imp.CompositeTransactionImp.doRollback(CompositeTransactionImp.java:237) [transactions-3.9.3.jar:na]
      at com.atomikos.icatch.imp.CompositeTerminatorImp.rollback(CompositeTerminatorImp.java:123) [transactions-3.9.3.jar:na]
      at com.atomikos.icatch.imp.CompositeTransactionImp.rollback(CompositeTransactionImp.java:346) [transactions-3.9.3.jar:na]
      at com.atomikos.icatch.jta.TransactionImp.rollback(TransactionImp.java:217) [transactions-jta-3.9.3.jar:na]
      at com.atomikos.icatch.jta.TransactionManagerImp.rollback(TransactionManagerImp.java:448) [transactions-jta-3.9.3.jar:na]
      at com.atomikos.icatch.jta.UserTransactionImp.rollback(UserTransactionImp.java:118) [transactions-jta-3.9.3.jar:na]
      at org.springframework.transaction.jta.JtaTransactionManager.doRollback(JtaTransactionManager.java:1048) [spring-tx-4.1.5.RELEASE.jar:4.1.5.RELEASE]
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:849) [spring-tx-4.1.5.RELEASE.jar:4.1.5.RELEASE]
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:826) [spring-tx-4.1.5.RELEASE.jar:4.1.5.RELEASE]
      at org.springframework.test.context.transaction.TransactionContext.endTransaction(TransactionContext.java:125) [spring-test-4.1.5.RELEASE.jar:4.1.5.RELEASE]
      at org.springframework.test.context.transaction.TransactionalTestExecutionListener.afterTestMethod(TransactionalTestExecutionListener.java:224) [spring-test-4.1.5.RELEASE.jar:4.1.5.RELEASE]
      at org.springframework.test.context.TestContextManager.afterTestMethod(TestContextManager.java:297) [spring-test-4.1.5.RELEASE.jar:4.1.5.RELEASE]
      at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:90) [spring-test-4.1.5.RELEASE.jar:4.1.5.RELEASE]
      at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:73) [spring-test-4.1.5.RELEASE.jar:4.1.5.RELEASE]
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) [junit-4.12.jar:4.12]
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:224) [spring-test-4.1.5.RELEASE.jar:4.1.5.RELEASE]
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:83) [spring-test-4.1.5.RELEASE.jar:4.1.5.RELEASE]
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-4.1.5.RELEASE.jar:4.1.5.RELEASE]
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:68) [spring-test-4.1.5.RELEASE.jar:4.1.5.RELEASE]
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:163) [spring-test-4.1.5.RELEASE.jar:4.1.5.RELEASE]
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) [.cp/:na]
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) [.cp/:na]
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) [.cp/:na]
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) [.cp/:na]
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) [.cp/:na]
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) [.cp/:na]
  11:50:17.411 [main] INFO  c.a.i.imp.CompositeTransactionImp - rollback() done of transaction 172.18.3.125.tm0000100096
  11:50:17.411 [main] INFO  o.s.t.c.t.TransactionContext - Rolled back transaction for test context [DefaultTestContext@2606b8 testClass = EmployeeRepositoryTest, testInstance = demo.EmployeeRepositoryTest@831e35, testMethod = saveBoth@EmployeeRepositoryTest, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@346762 testClass = EmployeeRepositoryTest, locations = '{classpath:applicationContext.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]].
  11:50:17.411 [main] DEBUG o.s.t.c.s.DirtiesContextTestExecutionListener - After test method: context [DefaultTestContext@2606b8 testClass = EmployeeRepositoryTest, testInstance = demo.EmployeeRepositoryTest@831e35, testMethod = saveBoth@EmployeeRepositoryTest, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@346762 testClass = EmployeeRepositoryTest, locations = '{classpath:applicationContext.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]], class dirties context [false], class mode [null], method dirties context [false].
  11:50:17.421 [main] DEBUG o.s.t.c.s.DirtiesContextTestExecutionListener - After test class: context [DefaultTestContext@2606b8 testClass = EmployeeRepositoryTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@346762 testClass = EmployeeRepositoryTest, locations = '{classpath:applicationContext.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]], dirtiesContext [false].
  11:50:17.422 [Thread-1] INFO  o.s.c.s.GenericApplicationContext - Closing org.springframework.context.support.GenericApplicationContext@1a1732d: startup date [Wed Mar 04 11:50:15 CET 2015]; root of context hierarchy
  11:50:17.422 [Thread-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleProcessor'
  11:50:17.422 [Thread-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1865381: defining beans [org.springframework.context.config.internalBeanConfigurerAspect,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,storeServiceImpl,org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension#0,org.springframework.data.repository.core.support.RepositoryInterfaceAwareBeanPostProcessor,foo,jpaMappingContext,employeeARepository,employeeBRepository,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,transactionManager,dataSourceA,dataSourceB,entityManagerFactoryA,entityManagerFactoryB,atomikosTransactionManager,atomikosUserTransaction,setMyAtomikosSystemProps,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor,org.springframework.orm.jpa.SharedEntityManagerCreator#0,org.springframework.orm.jpa.SharedEntityManagerCreator#1]; root of factory hierarchy
  </code></pre>
  
  <p>We are using Springboot 1.2.2, Atomikos 3.9.3, Hibernate 4.3.7 and SQL Server 2008.</p>
  
  <p>Most of our configurations is in the persistence.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&gt;
  
      &lt;persistence-unit name="PersistenceUnitA"
          transaction-type="JTA"&gt;
          &lt;class&gt;demo.entities.employeea.EmployeeA&lt;/class&gt;
          &lt;properties&gt;
              &lt;property name="hibernate.transaction.manager_lookup_class"
                  value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup" /&gt;
              &lt;property name="hibernate.transaction.factory_class"
                  value="org.hibernate.transaction.CMTTransactionFactory" /&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  
      &lt;persistence-unit name="PersistenceUnitB"
          transaction-type="JTA"&gt;
          &lt;class&gt;demo.entities.employeeb.EmployeeB&lt;/class&gt;
          &lt;properties&gt;
              &lt;property name="hibernate.transaction.manager_lookup_class"
                  value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup" /&gt;
              &lt;property name="hibernate.transaction.factory_class"
                  value="org.hibernate.transaction.CMTTransactionFactory" /&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  
  &lt;/persistence&gt;
  </code></pre>
  
  <p>And in the applicatioContext.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  
  // xmlns configuration
  
  &lt;context:spring-configured /&gt;
  
  &lt;context:component-scan base-package="demo.entities" /&gt;
  &lt;context:component-scan base-package="demo.service" /&gt;
  &lt;jpa:repositories base-package="demo.repositories.employeea"
      entity-manager-factory-ref="entityManagerFactoryA" /&gt;
  &lt;jpa:repositories base-package="demo.repositories.employeeb"
      entity-manager-factory-ref="entityManagerFactoryB" /&gt;
  &lt;tx:annotation-driven /&gt;
  &lt;tx:jta-transaction-manager /&gt;
  
  &lt;bean id="dataSourceA" class="com.atomikos.jdbc.AtomikosDataSourceBean"
      init-method="init" destroy-method="close"&gt;
      &lt;property name="uniqueResourceName"&gt;
          &lt;value&gt;DataSourceA&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="xaDataSourceClassName"&gt;
          &lt;value&gt;com.microsoft.sqlserver.jdbc.SQLServerXADataSource&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="xaProperties"&gt;
          &lt;props&gt;
              &lt;prop key="databaseName"&gt;bbdd1&lt;/prop&gt;
              &lt;prop key="serverName"&gt;localhost&lt;/prop&gt;
              &lt;prop key="user"&gt;****&lt;/prop&gt;
              &lt;prop key="password"&gt;****&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
      &lt;property name="minPoolSize"&gt;
          &lt;value&gt;1&lt;/value&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="dataSourceB" class="com.atomikos.jdbc.AtomikosDataSourceBean"
      init-method="init" destroy-method="close"&gt;
      &lt;property name="uniqueResourceName"&gt;
          &lt;value&gt;DataSourceB&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="xaDataSourceClassName"&gt;
          &lt;value&gt;com.microsoft.sqlserver.jdbc.SQLServerXADataSource&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="xaProperties"&gt;
          &lt;props&gt;
              &lt;prop key="databaseName"&gt;bbdd2&lt;/prop&gt;
              &lt;prop key="serverName"&gt;localhost&lt;/prop&gt;
              &lt;prop key="user"&gt;****&lt;/prop&gt;
              &lt;prop key="password"&gt;****&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
      &lt;property name="minPoolSize"&gt;
          &lt;value&gt;1&lt;/value&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="entityManagerFactoryA"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
      &lt;property name="persistenceXmlLocation"&gt;
          &lt;value&gt;classpath*:persistence.xml&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="persistenceUnitName" value="PersistenceUnitA" /&gt;
      &lt;property name="dataSource" ref="dataSourceA" /&gt;
      &lt;property name="jpaVendorAdapter"&gt;
          &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
              &lt;property name="showSql" value="true" /&gt;
              &lt;property name="databasePlatform" value="org.hibernate.dialect.SQLServerDialect" /&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="entityManagerFactoryB"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
      &lt;property name="persistenceXmlLocation"&gt;
          &lt;value&gt;classpath*:persistence.xml&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="persistenceUnitName" value="PersistenceUnitB" /&gt;
      &lt;property name="dataSource" ref="dataSourceB" /&gt;
      &lt;property name="jpaVendorAdapter"&gt;
          &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
              &lt;property name="showSql" value="true" /&gt;
              &lt;property name="databasePlatform" value="org.hibernate.dialect.SQLServerDialect" /&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" depends-on="setMyAtomikosSystemProps"
      init-method="init" destroy-method="close"&gt;
      &lt;property name="forceShutdown" value="false" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp" depends-on="setMyAtomikosSystemProps"&gt;
      &lt;property name="transactionTimeout" value="300" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="transactionManager"
      class="org.springframework.transaction.jta.JtaTransactionManager"
      depends-on="atomikosTransactionManager,atomikosUserTransaction"&gt;
      &lt;property name="transactionManager" ref="atomikosTransactionManager" /&gt;
      &lt;property name="userTransaction" ref="atomikosUserTransaction" /&gt;
      &lt;property name="allowCustomIsolationLevels" value="true" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="setMyAtomikosSystemProps"
      class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"&gt;
      &lt;property name="targetObject"&gt;
          &lt;!-- System.getProperties() --&gt;
          &lt;bean
              class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"&gt;
              &lt;property name="targetClass" value="java.lang.System" /&gt;
              &lt;property name="targetMethod" value="getProperties" /&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
      &lt;property name="targetMethod" value="putAll" /&gt;
      &lt;property name="arguments"&gt;
          &lt;!-- The new Properties --&gt;
          &lt;util:properties&gt;
              &lt;prop key="com.atomikos.icatch.file"&gt;classpath:jta.properties&lt;/prop&gt;
              &lt;prop key="com.atomikos.icatch.hide_init_file_path"&gt;true&lt;/prop&gt;
          &lt;/util:properties&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>
  
  <p>My @Repositories are empty, they just extends JpaRepository, in fact they are just interfaces.</p>
  
  <p>My test class:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration("classpath:applicationContext.xml")
  //@SpringApplicationConfiguration(classes = MainConfig.class)
  @Transactional
  @TransactionConfiguration(transactionManager = "transactionManager",     defaultRollback = true)
  public class EmployeeRepositoryTest {
  
  @Autowired
  private EmployeeARepository employeeARepository;
  
  @Autowired
  private EmployeeBRepository employeeBRepository;
  
  @Autowired
  private StoreService storeService;
  
  @Test
  public void saveBoth() {
      EmployeeA c = new EmployeeA();
      c.setId("101");
      c.setName("test-name");
      c.setAge(30);
      EmployeeB b = new EmployeeB();
      b.setId("102");
      b.setName("test-name");
      b.setAge(31);
      try {
          storeService.store(c, b);
      } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      /*Asserts*/
  }
  ...
  </code></pre>
  
  <p>I'm in the limit of the post, any other information needed will be given into comments.</p>
  
  <p>Any suggestions to why the transaction seems not to be joining Hibernate?</p>
  
  <p>Thank you.</p>