You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by Rajini Sivaram <ra...@googlemail.com> on 2007/07/11 10:12:47 UTC

Bundle classloaders and annotations

Hello,

I have a question related to annotations which is not specific to Felix, but
related to OSGi bundle classloaders. I imagine someone on this list will
know the answer, so I thought this is as good a place as any to ask the
question.

I would like to start using SCA annotations inside classes used in an OSGi
bundle. I have a bundle containing SCA annotations, and other bundles which
wish to use SCA annotations import the annotations package. So I have classA
loaded from bundleA which uses annotationB from bundleB. When I call
classA.getAnnotations(), I get an TypeNotPresentException for annotationB
since classA's classloader cannot see annotationB. It looks like a
reasonable exception since classA and annotationB belong to different
classloader hierarchies.

Is there any way a bundle can use annotations defined in another bundle?

Thank you...

Regards,

Rajini

Re[2]: Bundle classloaders and annotations

Posted by Peter Kriens <Pe...@aQute.biz>.
Use bnd, it will detect the types of the annotations and import them
accordingly ...

Kind regards,

     Peter Kriens
     
RS> Karl,

RS> Sorry, that was my fault since the Bundle-Classpath for the SCA annotations
RS> jar was not set correctly in the bundle. Now I just have the problem that
RS> the Tuscany code that processes the annotations sees different annotation
RS> classes from the one used by the bundle. Once I rewrite that code, hopefully
RS> it will all work properly.


RS> Thank you...

RS> Regards,

RS> Rajini


RS> On 7/11/07, Karl Pauls <ka...@gmail.com> wrote:
>>
>> Does bundleA import the package containing annotationB?
>>
>> regards,
>>
>> Karl
>>
>> On 7/11/07, Rajini Sivaram < rajinisivaram@googlemail.com> wrote:
>> > Hello,
>> >
>> > I have a question related to annotations which is not specific to Felix,
>> but
>> > related to OSGi bundle classloaders. I imagine someone on this list will
>>
>> > know the answer, so I thought this is as good a place as any to ask the
>> > question.
>> >
>> > I would like to start using SCA annotations inside classes used in an
>> OSGi
>> > bundle. I have a bundle containing SCA annotations, and other bundles
>> which
>> > wish to use SCA annotations import the annotations package. So I have
>> classA
>> > loaded from bundleA which uses annotationB from bundleB. When I call
>> > classA.getAnnotations(), I get an TypeNotPresentException for
>> annotationB
>> > since classA's classloader cannot see annotationB. It looks like a
>> > reasonable exception since classA and annotationB belong to different
>> > classloader hierarchies.
>> >
>> > Is there any way a bundle can use annotations defined in another bundle?
>>
>> >
>> > Thank you...
>> >
>> > Regards,
>> >
>> > Rajini
>> >
>>
>>
>> --
>> Karl Pauls
>> karlpauls@gmail.com
>>


-- 
Peter Kriens                              Tel +33467542167
9C, Avenue St. Drézéry                    AOL,Yahoo: pkriens
34160 Beaulieu, France                    ICQ 255570717
Skype pkriens                             Fax +1 8153772599


Re: Bundle classloaders and annotations

Posted by Rajini Sivaram <ra...@googlemail.com>.
Karl,

Sorry, that was my fault since the Bundle-Classpath for the SCA annotations
jar was not set correctly in the bundle. Now I just have the problem that
the Tuscany code that processes the annotations sees different annotation
classes from the one used by the bundle. Once I rewrite that code, hopefully
it will all work properly.


Thank you...

Regards,

Rajini


On 7/11/07, Karl Pauls <ka...@gmail.com> wrote:
>
> Does bundleA import the package containing annotationB?
>
> regards,
>
> Karl
>
> On 7/11/07, Rajini Sivaram < rajinisivaram@googlemail.com> wrote:
> > Hello,
> >
> > I have a question related to annotations which is not specific to Felix,
> but
> > related to OSGi bundle classloaders. I imagine someone on this list will
>
> > know the answer, so I thought this is as good a place as any to ask the
> > question.
> >
> > I would like to start using SCA annotations inside classes used in an
> OSGi
> > bundle. I have a bundle containing SCA annotations, and other bundles
> which
> > wish to use SCA annotations import the annotations package. So I have
> classA
> > loaded from bundleA which uses annotationB from bundleB. When I call
> > classA.getAnnotations(), I get an TypeNotPresentException for
> annotationB
> > since classA's classloader cannot see annotationB. It looks like a
> > reasonable exception since classA and annotationB belong to different
> > classloader hierarchies.
> >
> > Is there any way a bundle can use annotations defined in another bundle?
>
> >
> > Thank you...
> >
> > Regards,
> >
> > Rajini
> >
>
>
> --
> Karl Pauls
> karlpauls@gmail.com
>

Re: Bundle classloaders and annotations

Posted by Karl Pauls <ka...@gmail.com>.
Does bundleA import the package containing annotationB?

regards,

Karl

On 7/11/07, Rajini Sivaram <ra...@googlemail.com> wrote:
> Hello,
>
> I have a question related to annotations which is not specific to Felix, but
> related to OSGi bundle classloaders. I imagine someone on this list will
> know the answer, so I thought this is as good a place as any to ask the
> question.
>
> I would like to start using SCA annotations inside classes used in an OSGi
> bundle. I have a bundle containing SCA annotations, and other bundles which
> wish to use SCA annotations import the annotations package. So I have classA
> loaded from bundleA which uses annotationB from bundleB. When I call
> classA.getAnnotations(), I get an TypeNotPresentException for annotationB
> since classA's classloader cannot see annotationB. It looks like a
> reasonable exception since classA and annotationB belong to different
> classloader hierarchies.
>
> Is there any way a bundle can use annotations defined in another bundle?
>
> Thank you...
>
> Regards,
>
> Rajini
>


-- 
Karl Pauls
karlpauls@gmail.com