Hi, So using the EntityManagerFactoryBuilder and the JPAEntityManagerProviderFactory services is the lowest level way to set this up, and it requires a bit more setup than you are currently doing. I would normally recommend using configuration to directly create the JPAEntityManagerProvider for this reason.
There’s an example of using the programmatic API in the integration tests from Aries. https://github.com/apache/aries-tx-control/blob/1.0.0/tx-control-providers/jpa/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractJPATransactionTest.java#L187-L212 You can see that the first step is actually to create the raw DataSource that you want to use. This gets passed in the JPA properties using the “javax.persistence.dataSource” property. It needs to be an XADataSource if you want to use XA transactions. The second part of your code that needs to change is that neither of the two maps passed to the JPAEntityManagerProviderFactory are for JDBC setup. The first Map is the one passed to the EntityManagerFactoryBuilder to create an EntityManagerFactory. The second Map contains configuration for the scoped resource, such as pooling setup parameters. You can see a description of this in the JavaDoc for the method. https://osgi.org/javadoc/osgi.cmpn/7.0.0/org/osgi/service/transaction/control/jpa/JPAEntityManagerProviderFactory.html#getProviderFor-org.osgi.service.jpa.EntityManagerFactoryBuilder-java.util.Map-java.util.Map- Hopefully the example and documentation will be enough to help you through, but I can also recommend just using configuration to create the JPAEntityManagerProvider directly. The OSGi enRoute tutorial does show how you can do this. Injection and use of the provider: https://enroute.osgi.org/tutorial/032-tutorial_microservice-jpa.html#a-jpa-implementation Configuration used to set up the provider: https://enroute.osgi.org/tutorial/032-tutorial_microservice-jpa.html#runtime-configuration I hope this helps, Tim Sent from my iPhone > On 9 Feb 2019, at 10:23, cobusstroebel <co...@scss.co.za> wrote: > > When switching to the vanilla DataSourceFactory the error disappears but now > when I try to access the entity manager from the JPAEntityManagerProvider it > throws this error: > > /Unable to acquire a connection from driver [null], user [null] and URL > [null]. Verify that you have set the expected driver class and URL. Check > your login, persistence.xml or sessions.xml resource. The jdbc.driver > property should be set to a class that is compatible with your database > platform./ > > Please correct me if my understanding is wrong. Because I have specified all > the necessary properties in the > org.apache.aries.tx.controljpa.xa-example.cfg I can simply get the > JPAEntityManagerProvider with empty maps, like this: > > JPAEntityManagerProvider jpaProvider = > entityManagerProviderFactory.getProviderFor( > emfBuilder, > new HashMap<String, Object>(), //This would be additional jdbc > properties > new HashMap<String, Object>() //This would be additional jpa properties > ); > > Am I missing something? > > > > > -- > Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html