Hi,

Have you considered using OSGi Transaction Control rather than blueprint’s 
integration? Apache Aries has an implementation of this pre-release OSGi R7 
specification, and there are fewer moving parts. You can avoid deploying the 
blueprint/PAX JDBC pieces, and just use:

A JPA provider (OpenJPA 2.4, Hibernate 5.x, EclipseLink 2.6), 
Aries JPA Container 2.6.0 (none of the rest of Aries JPA will be needed)
Aries Transaction Control Service Local 
<https://github.com/apache/aries/tree/trunk/tx-control/tx-control-service-local>
 (0.0.2 is available in Maven Central)
Aries Transaction Control JPA Local 
<https://github.com/apache/aries/tree/trunk/tx-control/tx-control-provider-jpa-local>
 (0.0.2 is available in Maven Central)
H2 (your database of choice?) which is already a fully paid up OSGi 
implementation 

If you then cut down your persistence unit to the bare essentials:

<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence 
<http://xmlns.jcp.org/xml/ns/persistence>"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance 
<http://www.w3.org/2001/XMLSchema-instance>"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence 
<http://xmlns.jcp.org/xml/ns/persistence>
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd 
<http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd>">
 <persistence-unit name=“authentication" transaction-type="JTA">
   <!-- Is this really needed, i.e. do you use Hibernate specific 
annotations/API? --> 
   <provider>org.hibernate.ejb.HibernatePersistence</provider>
 </persistence-unit>
</persistence>

And create a factory configuration for pid 
org.apache.aries.tx.control.jpa.local containing:

osgi.unit.name=authentication
osgi.jdbc.driver.class=org.h2.Driver
url=<your h2 URL in here>

You should then be able to inject the Transaction Control service and the 
JPAEntityManagerProvider, just like in this example 
<https://github.com/apache/aries/blob/trunk/tx-control/tx-control-provider-jpa-local/README.md#creating-a-resource-using-a-factory-configuration>

I hope this helps,

Regards,

Tim 

> On 6 Jun 2017, at 16:36, smunro <stephen.ross.mu...@gmail.com> wrote:
> 
> Thanks jbonofre,
> 
> Looking at the sample, the main key differences I can see if your using
> openjpa and the jpa 1.0.0 spec.
> 
> I tried using the 5.2.9 of hibernate as well as add  org.hibernate.jpa to my
> import packages. I still shows the same log entry: 
> 
> waiting for dependencies
> [(&(osgi.unit.name=authentication)(objectClass=javax.persistence.EntityManager))]
> 
> The only other change I've noticed is the log entries that appear before
> that line:
> 
> 2017-06-06 16:31:25,504 | INFO  | nsole user karaf |
> PersistenceBundleTracker         | 96 - org.apache.aries.jpa.container -
> 2.3.0 | Found persistence unit authentication in bundle
> org.desolateplanet.authentication-db-impl with provider
> org.hibernate.ejb.HibernatePersistence.
> 2017-06-06 16:31:25,507 | INFO  | nsole user karaf |
> PersistenceBundleTracker         | 96 - org.apache.aries.jpa.container -
> 2.3.0 | Persistence units added for bundle
> org.desolateplanet.authentication-db-impl event 128
> 
> At this point, I'm just about ready to give up and go back to using raw jdbc
> calls :P
> 
> 
> 
> --
> View this message in context: 
> http://karaf.922171.n3.nabble.com/Hibernate-JPA-and-Karaf-4-tp4050569p4050587.html
> Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to