Given contract cannot be bound to a resource method

Richard Sand
 

Hi all,

I'm trying to apply a request interceptor to a specific resource provider class (which is in a 3rd party library), and I'm obviously doing it wrong. I am getting the error below - I'm a bit baffled as to the cause. The net effect is that the interceptor is being invoked on every request to every provider instead of the 1 provider. This is the error:

2017-11-26 10:43:51.061 [localhost-startStop-1][WARN][o.g.j.server.model.ResourceMethodConfig] - The given contract (interface javax.ws.rs.container.DynamicFeature) of class com.idfconnect.XYZ provider cannot be bound to a resource method.

The interceptor class is defined as:

@Provider

public class XYZ implements WriterInterceptor, DynamicFeature {


In my ResourceConfig I'm registering the interceptor for the specific provider as follows (I suspect this is where I've gone astray):

@ApplicationPath("service")

public class MyApp extends ResourceConfig {

    public SSORestApp() {

        ResourceConfig rc = register(SomeThirdPartyResource.class);

        rc.register(XYZ.class);


Can someone help me figure out how to bind the interceptor to SomeThirdPartyResource only?

Best regards,

Richard

Join jersey@javaee.groups.io to automatically receive all group messages.