Hey Tim,

that's what I tried earlier, but I seem to be missing something. When I
start the app, I can see that Hibernate is initialized. But the log then
contains a warning, which makes me think, that the JDBC connection is
not picked up / created:

WARN: HHH000342: Could not obtain connection to query metadata : null

Furthermore, when I inspect the PersonDaoImpl with scr:info, I can see
that the provider reference is unsatisfied. And from here I don't know
what to check to get it running.

My configuration looks like this (enroute configurer):
[
    {
        "service.factoryPid": "org.apache.aries.tx.control.jpa.local",
        "osgi.unit.name": "addressBookPU",
        "aries.dsf.target.filter": "(osgi.jdbc.driver.name=h2)",
        "user": "sa",
        "password": "",
        "databaseName": "mem:enroute_addressbook",
        "dataSourceName": "addressBookDS-H2",
        "url": "jdbc:h2:mem:enroute_addressbook;DB_CLOSE_DELAY=-1"
       
    }
]

and the persistence.xml:
<persistence xmlns="http://java.sun.com/xml/ns/persistence";
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd";
   version="2.0">
 
  <persistence-unit name="addressBookPU">
    <description>Persistence unit for the Transaction Control JPA
Example</description>
   
    <properties>
        <property name="hibernate.dialect"
value="org.hibernate.dialect.H2Dialect"/>
        <property
name="javax.persistence.schema-generation.database.action"
value="drop-and-create"/>
    </properties>
  </persistence-unit>
</persistence>


Greetings
Henrik


Am 08.09.2016 um 20:56 schrieb Timothy Ward:
> Hi Henrik
>
> The configuration “glue” that sticks these together is actually
> present in the test. 
>
> You need to provide a factory configuration for the JPA resource
> provider (factory pid org.apache.aries.tx.control.jpa.local)
>
> It needs to contain at a minimum:
>
>   * The name of the persistence unit (keyed using
>     the osgi.unit.name property)
>   * A way to identify the JDBC provider, either
>     the osgi.jdbc.driver.class property or the aries.dsf.target.filter)
>   * The connection information for the JDBC connection (e.g. the url)
>
>
> The full set of configuration is documented at the Apache Aries
> website
> at 
> http://aries.apache.org/modules/tx-control/localJPA.html#resource-provider-properties
>
>
> Regards,
>
> Tim
>
>
>> On 8 Sep 2016, at 10:12, Henrik Niehaus <henrik.nieh...@gmx.de
>> <mailto:henrik.nieh...@gmx.de>> wrote:
>>
>> Thanks Tim, that helped a lot already. I could never have figured out
>> all these special instructions in the bnd files.
>>
>> I can successfully run the ...dao.test as osgi framwork junit test. And
>> in my own application I'm also at the point that all dependencies of the
>> run descriptor can be resolved. I can also see, that hibernate comes up,
>> when I start the framework. But I still have no clue how to tie the
>> persistence unit and the datasource configuration together. So at the
>> moment hibernate is missing a datasource. I would like to be able to
>> configure a datasource with config admin and then somehow bind that DS
>> to the persistence unit.
>> It would be really kind of you, if you could have another look at the
>> example and adjust it, so that the application can be started without
>> errors.
>>
>> Regards
>> Henrik
>>
>> Am 08.09.2016 um 01:59 schrieb Timothy Ward:
>>> As requested:
>>>
>>>
>>> https://github.com/timothyjward/osgi.enroute.examples.jdbc/tree/jpa-example
>>>
>>> It’s a bit rough around the edges, but it sets up Hibernate, Aries
>>> JPA, Aries Transaction Control, and replaces the DAOs. The tests
>>> should all pass too.
>>>
>>>
>>> Regards,
>>>
>>> Tim
>>>
>>>
>>>> On 7 Sep 2016, at 09:40, Henrik Niehaus <henrik.nieh...@gmx.de
>>>> <mailto:henrik.nieh...@gmx.de>> wrote:
>>>>
>>>> Thanks Peter,
>>>> I actually got that working and used it to implement a MySQL backend
>>>> for Felix UserAdmin. But know I want to switch to JPA, because for
>>>> bigger object structures it gets quite complicated to do it all with
>>>> JDBC only. Unfortunately I cant get this reference
>>>>
>>>> @Reference EntityManagerFactoryBuilder emfb;
>>>>
>>>> to be resolved. That's why I was asking for an example.
>>>>
>>>> -Henrik
>>>>
>>>> Am 07.09.2016 um 18:34 schrieb Peter Kriens:
>>>>> You could take a look
>>>>> at https://github.com/osgi/osgi.enroute.examples.jdbc
>>>>>
>>>>> It wasn’t completely finished and reviewed but I think it works.
>>>>>
>>>>> Kind regards,
>>>>>
>>>>> Peter Kriens
>>>>>
>>>>>> On 7 sep. 2016, at 18:33, Henrik Niehaus <henrik.nieh...@gmx.de
>>>>>> <mailto:henrik.nieh...@gmx.de>
>>>>>> <mailto:henrik.nieh...@gmx.de>> wrote:
>>>>>>
>>>>>> Does anybody have a working example for tx-control with JPA? I know
>>>>>> there is a brief explation at [1], but I'm struggling with the
>>>>>> configuration and don't exactly know, which dependencies to use. It
>>>>>> would be very nice, if someone could provide a small self contained
>>>>>> code
>>>>>> example (preferably a bnd workspace).
>>>>>>
>>>>>> BR
>>>>>>
>>>>>> -Henrik
>>>>>>
>>>>>> [1] http://aries.apache.org/modules/tx-control/localJPA.html
>>>>>>
>>>>>> _______________________________________________
>>>>>> OSGi Developer Mail List
>>>>>> osgi-dev@mail.osgi.org
>>>>>> <mailto:osgi-dev@mail.osgi.org> <mailto:osgi-dev@mail.osgi.org>
>>>>>> https://mail.osgi.org/mailman/listinfo/osgi-dev
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> OSGi Developer Mail List
>>>>> osgi-dev@mail.osgi.org <mailto:osgi-dev@mail.osgi.org>
>>>>> https://mail.osgi.org/mailman/listinfo/osgi-dev
>>>>
>>>>
>>>> _______________________________________________
>>>> OSGi Developer Mail List
>>>> osgi-dev@mail.osgi.org
>>>> <mailto:osgi-dev@mail.osgi.org> <mailto:osgi-dev@mail.osgi.org>
>>>> https://mail.osgi.org/mailman/listinfo/osgi-dev
>>>
>>>
>>>
>>> _______________________________________________
>>> OSGi Developer Mail List
>>> osgi-dev@mail.osgi.org <mailto:osgi-dev@mail.osgi.org>
>>> https://mail.osgi.org/mailman/listinfo/osgi-dev
>>
>>
>> _______________________________________________
>> OSGi Developer Mail List
>> osgi-dev@mail.osgi.org <mailto:osgi-dev@mail.osgi.org>
>> https://mail.osgi.org/mailman/listinfo/osgi-dev
>
>
>
> _______________________________________________
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org
> https://mail.osgi.org/mailman/listinfo/osgi-dev


_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to