karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Schneider <ch...@die-schneider.net>
Subject Re: Injection Problem with JPA and Camel in Karaf 4.0.3
Date Thu, 07 Jan 2016 07:07:35 GMT
The two EntityManager services sound like there are maybe two aries jpa
container bundles present. Do you maybe install jpa 1.x and 2.x at the same
time? You should never do this as it will cause problems.

Mixing the new annotations of the blueprint-maven-plugin with xml should
work. You can let the maven plugin create one xml and also place another
one in the usual place. They will then be used together and can refer to
beans of each other.

So for example you can define the camel context in a manual xml and refer
to a RouteBuilder bean by id. This bean can be defined using annotations.
You just have to choose the id the maven plugin generates in the xml.

Christian


2016-01-06 14:12 GMT+01:00 cniehues <christian.niehues@its-telco.de>:

> 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.
>



-- 
-- 
Christian Schneider
http://www.liquid-reality.de
<https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.liquid-reality.de>

Open Source Architect
http://www.talend.com
<https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.talend.com>

Mime
View raw message