Hi Jack,

As I posted in response to Stephen in another thread, Aries Transaction Control 
makes sorting out JPA quite a lot simpler. You end up with just one 
configuration to manage. I’m including that post below. The significant 
difference for you is that obviously you’ll want a Postgres driver rather than 
H2, and a Postgres Driver name/URL in the configuration.

Regards,

Tim

——————

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 8 Jun 2017, at 09:09, smunro <stephen.ross.mu...@gmail.com> wrote:
> 
> Hello Jack,
> 
> I don't see anything in your example about creating a data source on karaf. 
> Have you defined a org.ops4j.datasource-<name>.cfg for karaf?
> 
> Take a look at https://github.com/desolate-planet/osgi-jpa-demo this is just
> a simple demo I created to get past my issue.
> 
> A few things to try, once you've deployed your data source and your bundle,
> try the following in karaf:
> 
> service:list DataSourceFactory
> service:list DataSource
> 
> The above will confirm you have a data source factory and a data source with
> the desired name (store).
> 
> If you can verify the data source is available on karaf with the store name,
> then the problem lies in your dependencies.
> 
> I don't have your code at hand to compare, but check my feature file to see
> the repositories used as well as the versions of each feature.
> 
> Stephen
> 
> 
> 
> 
> 
> 
> --
> View this message in context: 
> http://karaf.922171.n3.nabble.com/Hibernate-ORM-with-PostgresSql-with-Karaf-4-1-0-tp4050582p4050606.html
> Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to