Hello I'm currently working in a Karaf-based system where TransactionManager and DataSources are already provided through pax.jdbc.config, geronimo and aries aries.transaction.blueprint. I would like to introduce TransactionControl as provided by Aries and I'm trying to configure it with the following approach:
1. // Retrieve existing data source (provided via pax-jdbc): 2. DataSource dataSource = getService(bcontext, DataSource.class, "(osgi.jndi.service.name=target-persistence-unit)"); 3. Map<String, Object> jpaProps = new HashMap<>(); 4. jpaProps.put("javax.persistence.dataSource", dataSource); 5. EntityManagerFactoryBuilder emfb = getService(bcontext, EntityManagerFactoryBuilder.class); 6. JPAEntityManagerProviderFactory resourceProviderFactory = getService(bcontext, JPAEntityManagerProviderFactory.class); 7. EntityManager em = resourceProviderFactory.getProviderFor(emfb, jpaProps, jpaProps).getResource(txControl); Unfortunately line 7 fails with java.lang.IllegalArgumentException: The datasource supplied to create the EntityManagerFactory is not an XADataSource and so cannot be enlisted. Please provide either a javax.persistence.jtaDataSource, a javax.persistence.nonJtaDataSource, or a javax.persistence.dataSource which implements XADataSource at org.apache.aries.tx.control.jpa.xa.impl.JPAEntityManagerProviderFactoryImpl.handleNormalDataSource(JPAEntityManagerProviderFactoryImpl.java:184) at org.apache.aries.tx.control.jpa.xa.impl.JPAEntityManagerProviderFactoryImpl.getProviderFor(JPAEntityManagerProviderFactoryImpl.java:104) at org.apache.aries.tx.control.jpa.common.impl.ResourceTrackingJPAEntityManagerProviderFactory.lambda$getProviderFor$0(ResourceTrackingJPAEntityManagerProviderFactory.java:43) at org.apache.aries.tx.control.resource.common.impl.TrackingResourceProviderFactory.doGetResult(TrackingResourceProviderFactory.java:47) at org.apache.aries.tx.control.jpa.common.impl.ResourceTrackingJPAEntityManagerProviderFactory.getProviderFor(ResourceTrackingJPAEntityManagerProviderFactory.java:43) ... The Data Source is actually wrapped by DBCP2 and I guess this is why Aries fails to recognise it as a proper XA data source. Given that I must use existing TransactionManager (as provided by OSGi JTA Service spec) and pax.jdbc.config DataSources, my questions are Is this the right approach to configure the TransactionControl? I have the feeling that something is missing in Aries to support "external" DataSources and TransactionManager Could you please provide guidance on how to achieve this? I think this is somehow related to this post <http://karaf.922171.n3.nabble.com/OSGi-Transaction-control-fails-with-hibernate-td4051418.html>: is the content of that thread still actual? Many thanks, Matteo