Hello,
I just started with karaf and try to investigate how to migrate a
JMS/Camel/JPA related project to the OSGi world. So I created a little
test-project with following bundles:
  - a bundle containing persistence.xml and the model
  - a bundle containing the DAO service interface
  - a bundle containing the DAO service implementation
  - a bundle containing a bean calling the service within a camel timer
route

Because the blueprint.xml related injection of the EntityManager isn't
supported with the new version I tried to inject it with the blueprint
annotations but wasn't successful. So I imported the example from  Apache
Karaf Tutorial Part 9 - Annotation based blueprint and JPA
<http://www.liquid-reality.de/display/liquid/2015/03/05/Apache+Karaf+Tutorial+Part+9+-+Annotation+based+blueprint+and+JPA>
  
to call the taskService and noticed that get its EntityManager injected
successfully.

So I try to figure out what the difference is between the two DAO services.
My EntityManager is present as a service and the taskService also gets an
EntityManager when I change it to my persistence-unit. I only wonder why I
have two of each:
/[javax.persistence.EntityManager]
---------------------------------
 osgi.unit.name = tasklist
 service.bundleid = 188
 service.id = 240
 service.scope = singleton
Provided by : 
 model (188)
Used by: 
 persistence (189)

[javax.persistence.EntityManager]
---------------------------------
 osgi.unit.name = tasklist
 service.bundleid = 188
 service.id = 249
 service.scope = singleton
Provided by : 
 model (188)

[javax.persistence.EntityManager]
---------------------------------
 osgi.unit.name = pra
 service.bundleid = 191
 service.id = 256
 service.scope = singleton
Provided by : 
 pra-osgi-sid Bundle (191)

[javax.persistence.EntityManager]
---------------------------------
 osgi.unit.name = pra
 service.bundleid = 191
 service.id = 264
 service.scope = singleton
Provided by : 
 pra-osgi-sid Bundle (191)
/

I noticed that I had to inject my DAO service in my camel processing bean
with properties inside the blueprint.xml because the inject annotation
wasn't successfully. So I think the aries annotations don't work at all in
my projects.

I noticed the sentence "If the blueprint annotation service is available,
the bundle contains no blueprint definition XML" on the Aries blueprint
annotation website. Does this mean I can't combine blueprint annotations and
blueprint.xml? And if a blueprint.xml is present the blueprint annotation
isn't working? And how do I define my camel routes without the blueprint.xml
then?

btw: I noticed that some parts of the Developer Guide are missing for the
current version (CDI, Blueprint) on the karaf website. Also the jdbc
documentation is not up-to-date and the JPA part isn't documentated well at
all.

Greetings,
Christian



--
View this message in context: 
http://karaf.922171.n3.nabble.com/Injection-Problem-with-JPA-and-Camel-in-Karaf-4-0-3-tp4044627.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to