In Aries JPA 2.1.0 it was possible to colocate the persistence unit and the impl using the EntityManager. The reason is that in that version the EntityManager service is simply accessed using plain OSGi API. So the blueprint startup is not waiting for the service.

The problem with this behaviour is that if for some reason the EntityManager service is not coming up then your blueprint will still start and block during the first call until a timeout. This is probably not how you want your service to behave. You also had not indication in diag that something is wrong.

So in Aries JPA 2.2.0 I changed the code to correctly register a service reference for the EntityManager service in blueprint. So blueprint will delay the startup until the service is coming up. You will also be able to see that the service is missing using diag.

So the behavior with the new version is like if you try to provide and use the same service in the same blueprint file. It will never start up. So you will have to separate the
persistence unit from the code using the EntityManager to make it work.

Of course it would be great to be able to colocate and have a good startup behaviour at the same time but I have not found a way to do so. One option might be to register the service ref as optional but then you would have problems again if the EM does not come up.
If someone finds a good way then I am open to any suggestions about this.

Christian

Am 14.11.2015 um 14:14 schrieb conejo:
I have an example in this direction:

https://github.com/LuisLozano/karafExamples

When using version 2.2.0 org.apache.aries.jpa.blueprint service is not
displayed. However, using version 2.1.0 the service itself perfectly
displayed.



--
View this message in context: 
http://karaf.922171.n3.nabble.com/4-0-3-Karaf-JPA-problem-tp4043497p4043514.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to