I am currently trying to integrate Jersey (version 2.22.2) into a
OSGi runtime based on Apache Felix. To be able to use Declarative
Service references (@Reference) in my resources I need to control
the resource lifecycle with OSGi instead of Jersey.
Custom Life Cycle Management of the Jersey User Guide
illustrates how the resource lifecycle can be taken control over by
implementing the org.glassfish.jersey.server.spi.ComponentProvider
I did just that, but when I try to register my ComponentProvider
implementation I get the following error:
org.glassfish.jersey.server.spi.ComponentProvider can not be
registered for component class
de.jena.servicehub.rs.OsgiResourceProvider: Contract type not
I scoured the Jersey source code for the source of this error
and ended up at the org.glassfish.jersey.internal.inject.Providers
class's isSupportedContract(Class<?>) method. The
method checks whether the contract class of the class to be
registered (i.e. the implemented interface) is annotated with @Contract
or if it is on one of two white lists. Neither is true for the ComponentProvider
interface. Thus Jersey refuses to register my implementation.
Is this a bug or am I doing something wrong?
I am registering all providers and and resources programmatically on
a ResourceConfig instance which I use to initialize a ServletContainer
__________ Information from ESET Mail Security, version of virus signature database 14897 (20170207) __________