users@jersey.java.net

Re: [Jersey] Jersey in Felix

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 01 Dec 2008 10:40:58 +0100

Hi Richard,

On Nov 30, 2008, at 1:14 AM, Richard Wallace wrote:

> Hey all,
>
> I'm trying to get Jersey working in Felix and I'm running into a few
> problems.

Is w.r.t. to utilizing Jersey without specific support in GF v3
prelude? for example i understand that GF has support for META-INF/
services.

We realize we have to do some more work to improve on the OSGi
integration. For example currently for GF we rely on the jersey-
bundle.jar and IIRC pretty much every package is exported. The reason
being is that although Jersey was split into several maven modules the
package boundaries between them were not cleanly defined. This has
been fixed now so that modules only depend on API/SPI packages of
other modules and there is no package names shared between modules.
For the 1.0.2 release we hope to add proper OSGI information to each
module.

If there is any overlap between what you have done and what we would
like to do perhaps we can share the details on what additional work
you needed to do?


> I've solved most of them but the one I'm running into now
> is possibly a showstopper. In the FactoryFinder.find() method of the
> jsr311-api jar there is this call to get the class loader.
>
> classLoader =
> Thread.currentThread().getContextClassLoader();
>

The context class loader is used consistently throughout Jersey to
dynamically load classes: stuff from META-INF/services and classes
from names when class scanning for root resource and provider classes.


> The problem is that the thread class loader is not the bundle class
> loader so this fails to find the RuntimeDelegationImpl class.

And the RuntimeDelegationImpl will be in another bundle?


> The
> simplest solution is to wrap the initialization code in something that
> sets the threads context class loader to the bundles class loader.
> I'm worried that even if this works for the startup code, it may cause
> problems down the line. Any tips?
>

Hmm... i must admit to not being an expert in the class loading
esoteric nature of the JVM and how OSGi works in this respect. So it
is hard for me to know what problems, if any, this might induce. What
types of problem might you expect? What should i be looking for?

Thanks,
Paul.