You are right.

@Reference is only meaningful in an @Component. So this only works if your class is instantiated by DS.

If you want to use DS then I strongly recommend to start with my tutorial code:
https://github.com/cschneider/Karaf-Tutorial/tree/master/tasklist-ds

So at least you have a working base.

Again - Do not mix blueprint and DS in the same bundle. Choose one and use it for all classes in a bundle.

Christian

On 15.03.2017 09:21, erwan wrote:
I'm still working on a solution for my problem and for the moment Reference
injected doesn't seem to be filled.
I'm getting a NullPointerException every time I'm trying to access methods
on this @Reference.
What is difficult is that I found some key information in several sources.
For example, I found these lines in hibernate site:
"Technically, multiple persistence units are supported by Enterprise OSGi
JPA and unmanaged Hibernate JPA use. However, we cannot currently support
this in OSGi. In Hibernate 4, only one instance of the OSGi-specific
ClassLoader is used per Hibernate bundle, mainly due to heavy use of static
TCCL utilities. We hope to support one OSGi ClassLoader per persistence unit
in Hibernate 5.
Scanning is supported to find non-explicitly listed entities and mappings.
However, they MUST be in the same bundle as your persistence unit (fairly
typical anyway). Our OSGi ClassLoader only considers the "requesting bundle"
(hence the requirement on using services to create EMF/SF), rather than
attempting to scan all available bundles. This is primarily for versioning
considerations, collision protections, etc. "

I also see that a @Reference seems to be only taken into account inside a
@Component? is this right?

Maybe the way I use DS with hibernate isn't possible.



--
View this message in context: 
http://karaf.922171.n3.nabble.com/Multiple-bundles-dependencies-injection-pax-cdi-or-blueprint-tp4049756p4049851.html
Sent from the Karaf - User mailing list archive at Nabble.com.


--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Reply via email to