felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Walker <r...@ascert.com>
Subject Re: Has anyone used JAXB within Felix?
Date Wed, 21 Mar 2007 09:41:17 GMT

>
> Sorry.  I meant to respond to you previous post.  So far, I've been 
> unable to duplicate what you've done by putting the JAXB libs in the 
> same bundle as my schema generated classes.  Although this isn't the 
> best solution, I wanted to have some small success by duplicating your 
> solution.  What I'd really like to see is a solution that allows JAXB 
> to be bundled and added to the Felix commons.
>
> I do appreciate your response.  It tells me that I'm not fighting a 
> losing battle.  I just need to learn more about how imports, exports, 
> and class loading work in OSGi.
>
No worries - happy to keep you positive!

When I glanced back at our old code, I actually found very few JAXB libs 
that it actually seemed to need at runtime (i.e. that we'd built into 
bundles). I think the trick is getting your generated classes into 
something like a schema JAR that has all the right imports and exports.

Depending on your SAX parser, you might also need the old 
"setContextClassloader" fix, which is often needed because some XML/SAX 
classes find the classloader using the thread's context classloader e.g.

        
Thread.currentThread().setContextClassLoader(VtFormatLoader.class.getClassLoader());

Unfortunately, this may need to go anywhere you create a new thread - 
our app has a single place where we create threads, so we localised it 
in there.

-- Rob



Mime
View raw message