ComponentProvider ... Contract type not supported

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

ComponentProvider ... Contract type not supported

Frank Rosenberger
Hi,
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.
Chapter 23.3. 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 SPI.
I did just that, but when I try to register my ComponentProvider implementation I get the following error:

Contract interface org.glassfish.jersey.server.spi.ComponentProvider can not be registered for component class de.jena.servicehub.rs.OsgiResourceProvider: Contract type not supported.

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 instance.

Regards
Frank Rosenberger


__________ Information from ESET Mail Security, version of virus signature database 14897 (20170207) __________

The message was checked by ESET Mail Security.
http://www.eset.com
Loading...