felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "GERODOLLE Anne RD-MAPS-GRE" <anne.gerodo...@orange-ftgroup.com>
Subject RE: Has anyone used JAXB within Felix?
Date Wed, 21 Mar 2007 09:31:14 GMT
Hi,

I've had similar problem, and solved it by using jaxb methods that accept a classloader as
argument.

Ex : JAXBContext.newInstance(somepackage, myclassloader) will work, provided myclassloader
is able to load the generated class.

But if you call JAXBContext.newInstance(somepackage) it uses the Thread.getContextClassLoader
method and it won't work in OSGi.

You don't have to use a wild-carded dynamic import (and it even does not work).

However, I have not tested with felix, only with Oscar. I had also to provide the package
explicitely because the getPackage method would return null with classes loaded by the Oscar
class loader.

Regards,

Anne
-----Message d'origine-----
De : Rob Walker [mailto:robw@ascert.com] 
Envoyé : mercredi 21 mars 2007 10:09
À : felix-dev@incubator.apache.org
Objet : Re: Has anyone used JAXB within Felix?

I can answer part 2
> - If OSGi is using custom class loaders and JAXB is using different 
> class loaders, will JAXB ever work in OSGi?
>
Yes it will and it does - we did it some time ago and it worked fine (as per my earlier post)

In fact, I seem now to recall that JAX-B only actually has a very small set of runtime classes
- from memory mostly it's a build-time, generation tool. The Java classes it creates are mostly
standalone with needs largely on things like XML parsers. I seem to remember some namespace
handling and RI classes, and that was about it.  So it's mostly about bundling your generated
classes in a correct with all the necessary imports and exports.

-- Rob
> Thanks,
>  Tim
>
> Felix Meschberger wrote:
>> Hi,
>>
>> On 3/19/07, Tim Moloney <t.moloney@verizon.net> wrote:
>>> I've not worked with class loaders before.  How do I know which 
>>> class loaders are being used?  Where can I read more about them?
>>
>> Well, you "work with class loaders" all the time, but you don't know.
>> In fact, the whole OSGi Module spec is centered around Java 
>> ClassLoading. :-)
>>
>> You will find numerous documentation on class loading on the net, e.g.
>> http://www.javalobby.org/java/forums/t18345.html
>> http://www.onjava.com/pub/a/onjava/2005/01/26/classloading.html
>>
>> Point here is, that two Class instances loaded by different 
>> ClassLoader instances are not the same even thought their byte code 
>> might be exactly the same. And this is one of the tricky things 
>> regarding class loaders because this situation is somewhat difficult 
>> to trace.
>>
>>> I'm not sure that the source for JAXB is available but I'll look.
>>>
>>> Thanks for the suggestions.  :)
>>
>> You are welcome.
>>
>> Regards
>> Felix
>>
>

-- 


Ascert - Taking systems to the Edge
robw@ascert.com
+44 (0)20 7488 3470
www.ascert.com


Mime
View raw message