You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Thomas Draier <td...@jahia.com> on 2019/12/12 10:55:14 UTC

Karaf 4.2 and pax-cdi

Hi there,

I'm trying to make pax-cdi work within karaf (4.2), maybe somebody can help
?

I just installed the pax-cdi feature (which include pax-cdi 1.1.1) with
pax-cdi-openwebbeans . First my bundle was not detected by pax-cdi , as i
added a capability  requirement for osgi.extender;
filter:="(osgi.extender=pax.cdi)" , where it seems that pax-cdi only
detects osgi.extender; filter:="(osgi.extender=osgi.cdi)" . I don't clearly
get the difference between both ?

Then, to refer to an osgi service, the documentation refers to @OsgiService
annotation - but it seems that it has been removed from pax-cdi-api since
1.0.0 (it was in rc1) - in 1.1.1, I have a @Service annotation instead ,
but I still got an UnsatisfiedResolutionException on my @Inject @Service
 field - is there anything i need to enable so that it look in osgi
services ?

thanks !

-- 
Thomas Draier
Chief Software Architect & Co-Founder
T +33 1 44 79 37 86
8 rue du Sentier | 75002 Paris | France
jahia.com <http://www.jahia.com/>
SKYPE | VCARD <http://www.jahia.com/vcard/DraierThomas.vcf>


> JOIN OUR COMMUNITY <http://www.jahia.com/> to evaluate, get trained and
to discover why Jahia is a leading User Experience Platform (UXP) for
Digital Transformation.

Re: Karaf 4.2 and pax-cdi

Posted by Thomas Draier <td...@jahia.com>.
Hi,

Here's a sample code to reproduce the issue. The injection of
ConfigurationAdmin works fine in Component2, but not in Component1. The
bundle correctly wires and starts up if you remove the injection from
Component2, or makes Component2 immediate and remove injection from
Component1 to Component2.

Regards
Thomas


On Fri, Dec 13, 2019 at 1:23 PM Jean-Baptiste Onofré <jb...@nanthrax.net>
wrote:

> Hi,
>
> Adding javax.annotation in bootdelegation or endorsed is not a good
> option. Generally speaking, we should remove the one coming from the JVM
> and prefer bundles.
> I will improve the situation.
>
> Anyway, I will update the reference and documentation about @Service
> (@OsgiService is deprecated/removed).
>
> I already created https://issues.apache.org/jira/browse/KARAF-6434 to
> illustrate CDI in Karaf.
> I already have something, just have to add the corresponding itests.
>
> Your issue looks like a race condition and a tracker issue in Pax CDI.
> Let me try to reproduce.
>
> I keep you posted.
>
> Regards
> JB
>
> On 13/12/2019 11:25, Thomas Draier wrote:
> > Hi JB,
> >
> > I finally found my issue - it was a duplicate class for javax.annotation
> > which was breaking some detection inside pax-cdi. One is coming from a
> > bundle (required for jax-rs, i think) , and one coming from the jvm. I
> > don't know if this is a correct solution, but adding javax.annotation to
> > the bootdelegation configuration completely solved the problem.
> >
> > By the way, we need to use the @Service annotation indeed, @OsgiService
> > does not exist anymore, even if it is still documented everywhere (even
> > in pax-cdi manual).
> >
> > Still, I had a strange issue with pax-cdi and osgi service - this kind
> > of injection :
> >
> > Component1 (@Immediate) -> Component2 -> OSGI service
> >
> > does not work. Component1 is activated, injects a new instance of
> > component2, which try to inject the osgi service - but it cannot resolve
> > the OSGi service, because the
> > org.osgi.service.component.ComponentContext is not set in the
> > ComponentManager of Component2. If Component2 is directly activated
> > (with an immediate, and not as a cause of an injection), it works well
> > (  Component2 (@Immediate) -> OSGI service ). I did not completely get
> > the sequence, but the activation of Component2 does not go into the same
> > code in both cases.
> >
> > I also wanted to test aries-cdi, but since there's no feature provided
> > by default i figured that pax-cdi was more "supported" by karaf.
> >
> > Thanks
> >
> >
> >
> > On Thu, Dec 12, 2019 at 4:02 PM Jean-Baptiste Onofré <jb@nanthrax.net
> > <ma...@nanthrax.net>> wrote:
> >
> >     Hi Thomas,
> >
> >     By the way, you also have Aries CDI which is interesting.
> >
> >     Regarding Pax CDI, don't you have a missing service requirement ? If
> so,
> >     it's not runtime issue but more cap/req deployment issue.
> >     Check if you don't have a Require-Service in your MANIFEST. Then, you
> >     would need a feature/bundle providing the capability.
> >
> >     Regards
> >     JB
> >
> >     On 12/12/2019 11:55, Thomas Draier wrote:
> >     > Hi there,
> >     >
> >     > I'm trying to make pax-cdi work within karaf (4.2), maybe somebody
> can
> >     > help ?
> >     >
> >     > I just installed the pax-cdi feature (which include pax-cdi 1.1.1)
> >     with
> >     > pax-cdi-openwebbeans . First my bundle was not detected by pax-cdi
> >     , as
> >     > i added a capability  requirement for osgi.extender;
> >     > filter:="(osgi.extender=pax.cdi)" , where it seems that pax-cdi
> only
> >     > detects osgi.extender; filter:="(osgi.extender=osgi.cdi)" . I don't
> >     > clearly get the difference between both ?
> >     >
> >     > Then, to refer to an osgi service, the documentation refers to
> >     > @OsgiService annotation - but it seems that it has been removed
> from
> >     > pax-cdi-api since 1.0.0 (it was in rc1) - in 1.1.1, I have a
> @Service
> >     > annotation instead , but I still got an
> UnsatisfiedResolutionException
> >     > on my @Inject @Service  field - is there anything i need to enable
> so
> >     > that it look in osgi services ?
> >     >
> >     > thanks !
> >     >
> >     > --
> >     >
> >     >
> >     >   Thomas Draier
> >     >   Chief Software Architect & Co-Founder
> >     >
> >     > T +33 1 44 79 37 86
> >     > 8 rue du Sentier | 75002 Paris | France
> >     > jahia.com <http://jahia.com> <http://www.jahia.com/>
> >     > SKYPE | VCARD <http://www.jahia.com/vcard/DraierThomas.vcf>
> >     >
> >     >
> >     >> JOIN OUR COMMUNITY <http://www.jahia.com/> to evaluate, get
> trained
> >     > and to discover why Jahia is a leading User Experience Platform
> (UXP)
> >     > for Digital Transformation.
> >
> >     --
> >     Jean-Baptiste Onofré
> >     jbonofre@apache.org <ma...@apache.org>
> >     http://blog.nanthrax.net
> >     Talend - http://www.talend.com
> >
> >
> >
> > --
> >
> >
> >   Thomas Draier
> >   Chief Software Architect & Co-Founder
> >
> > T +33 1 44 79 37 86
> > 8 rue du Sentier | 75002 Paris | France
> > jahia.com <http://www.jahia.com/>
> > SKYPE | VCARD <http://www.jahia.com/vcard/DraierThomas.vcf>
> >
> >
> >> JOIN OUR COMMUNITY <http://www.jahia.com/> to evaluate, get trained
> > and to discover why Jahia is a leading User Experience Platform (UXP)
> > for Digital Transformation.
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>


-- 
Thomas Draier
Chief Software Architect & Co-Founder
T +33 1 44 79 37 86
8 rue du Sentier | 75002 Paris | France
jahia.com <http://www.jahia.com/>
SKYPE | VCARD <http://www.jahia.com/vcard/DraierThomas.vcf>


> JOIN OUR COMMUNITY <http://www.jahia.com/> to evaluate, get trained and
to discover why Jahia is a leading User Experience Platform (UXP) for
Digital Transformation.

Re: Karaf 4.2 and pax-cdi

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,

Adding javax.annotation in bootdelegation or endorsed is not a good
option. Generally speaking, we should remove the one coming from the JVM
and prefer bundles.
I will improve the situation.

Anyway, I will update the reference and documentation about @Service
(@OsgiService is deprecated/removed).

I already created https://issues.apache.org/jira/browse/KARAF-6434 to
illustrate CDI in Karaf.
I already have something, just have to add the corresponding itests.

Your issue looks like a race condition and a tracker issue in Pax CDI.
Let me try to reproduce.

I keep you posted.

Regards
JB

On 13/12/2019 11:25, Thomas Draier wrote:
> Hi JB,
> 
> I finally found my issue - it was a duplicate class for javax.annotation
> which was breaking some detection inside pax-cdi. One is coming from a
> bundle (required for jax-rs, i think) , and one coming from the jvm. I
> don't know if this is a correct solution, but adding javax.annotation to
> the bootdelegation configuration completely solved the problem.
> 
> By the way, we need to use the @Service annotation indeed, @OsgiService
> does not exist anymore, even if it is still documented everywhere (even
> in pax-cdi manual).
> 
> Still, I had a strange issue with pax-cdi and osgi service - this kind
> of injection :
> 
> Component1 (@Immediate) -> Component2 -> OSGI service 
> 
> does not work. Component1 is activated, injects a new instance of
> component2, which try to inject the osgi service - but it cannot resolve
> the OSGi service, because the
> org.osgi.service.component.ComponentContext is not set in the
> ComponentManager of Component2. If Component2 is directly activated
> (with an immediate, and not as a cause of an injection), it works well
> (  Component2 (@Immediate) -> OSGI service ). I did not completely get
> the sequence, but the activation of Component2 does not go into the same
> code in both cases.
> 
> I also wanted to test aries-cdi, but since there's no feature provided
> by default i figured that pax-cdi was more "supported" by karaf. 
> 
> Thanks
> 
> 
> 
> On Thu, Dec 12, 2019 at 4:02 PM Jean-Baptiste Onofré <jb@nanthrax.net
> <ma...@nanthrax.net>> wrote:
> 
>     Hi Thomas,
> 
>     By the way, you also have Aries CDI which is interesting.
> 
>     Regarding Pax CDI, don't you have a missing service requirement ? If so,
>     it's not runtime issue but more cap/req deployment issue.
>     Check if you don't have a Require-Service in your MANIFEST. Then, you
>     would need a feature/bundle providing the capability.
> 
>     Regards
>     JB
> 
>     On 12/12/2019 11:55, Thomas Draier wrote:
>     > Hi there, 
>     >
>     > I'm trying to make pax-cdi work within karaf (4.2), maybe somebody can
>     > help ?  
>     >
>     > I just installed the pax-cdi feature (which include pax-cdi 1.1.1)
>     with
>     > pax-cdi-openwebbeans . First my bundle was not detected by pax-cdi
>     , as
>     > i added a capability  requirement for osgi.extender;
>     > filter:="(osgi.extender=pax.cdi)" , where it seems that pax-cdi only
>     > detects osgi.extender; filter:="(osgi.extender=osgi.cdi)" . I don't
>     > clearly get the difference between both ?
>     >
>     > Then, to refer to an osgi service, the documentation refers to
>     > @OsgiService annotation - but it seems that it has been removed from
>     > pax-cdi-api since 1.0.0 (it was in rc1) - in 1.1.1, I have a @Service
>     > annotation instead , but I still got an UnsatisfiedResolutionException
>     > on my @Inject @Service  field - is there anything i need to enable so
>     > that it look in osgi services ?
>     >
>     > thanks !
>     >
>     > --
>     >
>     >
>     >   Thomas Draier
>     >   Chief Software Architect & Co-Founder
>     >
>     > T +33 1 44 79 37 86
>     > 8 rue du Sentier | 75002 Paris | France
>     > jahia.com <http://jahia.com> <http://www.jahia.com/>
>     > SKYPE | VCARD <http://www.jahia.com/vcard/DraierThomas.vcf>
>     >   
>     >
>     >> JOIN OUR COMMUNITY <http://www.jahia.com/> to evaluate, get trained
>     > and to discover why Jahia is a leading User Experience Platform (UXP)
>     > for Digital Transformation.
> 
>     -- 
>     Jean-Baptiste Onofré
>     jbonofre@apache.org <ma...@apache.org>
>     http://blog.nanthrax.net
>     Talend - http://www.talend.com
> 
> 
> 
> -- 
> 
> 
>   Thomas Draier
>   Chief Software Architect & Co-Founder
> 
> T +33 1 44 79 37 86
> 8 rue du Sentier | 75002 Paris | France
> jahia.com <http://www.jahia.com/>
> SKYPE | VCARD <http://www.jahia.com/vcard/DraierThomas.vcf>
>   
> 
>> JOIN OUR COMMUNITY <http://www.jahia.com/> to evaluate, get trained
> and to discover why Jahia is a leading User Experience Platform (UXP)
> for Digital Transformation.

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Karaf 4.2 and pax-cdi

Posted by Thomas Draier <td...@jahia.com>.
Hi JB,

I finally found my issue - it was a duplicate class for javax.annotation
which was breaking some detection inside pax-cdi. One is coming from a
bundle (required for jax-rs, i think) , and one coming from the jvm. I
don't know if this is a correct solution, but adding javax.annotation to
the bootdelegation configuration completely solved the problem.

By the way, we need to use the @Service annotation indeed, @OsgiService
does not exist anymore, even if it is still documented everywhere (even in
pax-cdi manual).

Still, I had a strange issue with pax-cdi and osgi service - this kind of
injection :

Component1 (@Immediate) -> Component2 -> OSGI service

does not work. Component1 is activated, injects a new instance of
component2, which try to inject the osgi service - but it cannot resolve
the OSGi service, because the org.osgi.service.component.ComponentContext
is not set in the ComponentManager of Component2. If Component2 is directly
activated (with an immediate, and not as a cause of an injection), it works
well (  Component2 (@Immediate) -> OSGI service ). I did not completely get
the sequence, but the activation of Component2 does not go into the same
code in both cases.

I also wanted to test aries-cdi, but since there's no feature provided by
default i figured that pax-cdi was more "supported" by karaf.

Thanks



On Thu, Dec 12, 2019 at 4:02 PM Jean-Baptiste Onofré <jb...@nanthrax.net>
wrote:

> Hi Thomas,
>
> By the way, you also have Aries CDI which is interesting.
>
> Regarding Pax CDI, don't you have a missing service requirement ? If so,
> it's not runtime issue but more cap/req deployment issue.
> Check if you don't have a Require-Service in your MANIFEST. Then, you
> would need a feature/bundle providing the capability.
>
> Regards
> JB
>
> On 12/12/2019 11:55, Thomas Draier wrote:
> > Hi there,
> >
> > I'm trying to make pax-cdi work within karaf (4.2), maybe somebody can
> > help ?
> >
> > I just installed the pax-cdi feature (which include pax-cdi 1.1.1) with
> > pax-cdi-openwebbeans . First my bundle was not detected by pax-cdi , as
> > i added a capability  requirement for osgi.extender;
> > filter:="(osgi.extender=pax.cdi)" , where it seems that pax-cdi only
> > detects osgi.extender; filter:="(osgi.extender=osgi.cdi)" . I don't
> > clearly get the difference between both ?
> >
> > Then, to refer to an osgi service, the documentation refers to
> > @OsgiService annotation - but it seems that it has been removed from
> > pax-cdi-api since 1.0.0 (it was in rc1) - in 1.1.1, I have a @Service
> > annotation instead , but I still got an UnsatisfiedResolutionException
> > on my @Inject @Service  field - is there anything i need to enable so
> > that it look in osgi services ?
> >
> > thanks !
> >
> > --
> >
> >
> >   Thomas Draier
> >   Chief Software Architect & Co-Founder
> >
> > T +33 1 44 79 37 86
> > 8 rue du Sentier | 75002 Paris | France
> > jahia.com <http://www.jahia.com/>
> > SKYPE | VCARD <http://www.jahia.com/vcard/DraierThomas.vcf>
> >
> >
> >> JOIN OUR COMMUNITY <http://www.jahia.com/> to evaluate, get trained
> > and to discover why Jahia is a leading User Experience Platform (UXP)
> > for Digital Transformation.
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>


-- 
Thomas Draier
Chief Software Architect & Co-Founder
T +33 1 44 79 37 86
8 rue du Sentier | 75002 Paris | France
jahia.com <http://www.jahia.com/>
SKYPE | VCARD <http://www.jahia.com/vcard/DraierThomas.vcf>


> JOIN OUR COMMUNITY <http://www.jahia.com/> to evaluate, get trained and
to discover why Jahia is a leading User Experience Platform (UXP) for
Digital Transformation.

Re: Karaf 4.2 and pax-cdi

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Thomas,

By the way, you also have Aries CDI which is interesting.

Regarding Pax CDI, don't you have a missing service requirement ? If so,
it's not runtime issue but more cap/req deployment issue.
Check if you don't have a Require-Service in your MANIFEST. Then, you
would need a feature/bundle providing the capability.

Regards
JB

On 12/12/2019 11:55, Thomas Draier wrote:
> Hi there, 
> 
> I'm trying to make pax-cdi work within karaf (4.2), maybe somebody can
> help ?  
> 
> I just installed the pax-cdi feature (which include pax-cdi 1.1.1) with
> pax-cdi-openwebbeans . First my bundle was not detected by pax-cdi , as
> i added a capability  requirement for osgi.extender;
> filter:="(osgi.extender=pax.cdi)" , where it seems that pax-cdi only
> detects osgi.extender; filter:="(osgi.extender=osgi.cdi)" . I don't
> clearly get the difference between both ?
> 
> Then, to refer to an osgi service, the documentation refers to
> @OsgiService annotation - but it seems that it has been removed from
> pax-cdi-api since 1.0.0 (it was in rc1) - in 1.1.1, I have a @Service
> annotation instead , but I still got an UnsatisfiedResolutionException
> on my @Inject @Service  field - is there anything i need to enable so
> that it look in osgi services ?
> 
> thanks !
> 
> -- 
> 
> 
>   Thomas Draier
>   Chief Software Architect & Co-Founder
> 
> T +33 1 44 79 37 86
> 8 rue du Sentier | 75002 Paris | France
> jahia.com <http://www.jahia.com/>
> SKYPE | VCARD <http://www.jahia.com/vcard/DraierThomas.vcf>
>   
> 
>> JOIN OUR COMMUNITY <http://www.jahia.com/> to evaluate, get trained
> and to discover why Jahia is a leading User Experience Platform (UXP)
> for Digital Transformation.

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com