title: Jersey Provider is not getting Context programmatically
body: <p>I have REST webservices being brought up in Jersey programmatically and I need it to wrap a call to a 2PP Provider for AuthN/AuthZ purposes. The problem is that the 2PP Provider is not able to resolve the @Context. I have provided below a sample snippet of what code is being done.</p>
  
  <p><strong>Provider that needs to be integrated</strong>:</p>
  
  <pre><code>package com.fctest.restful.hello.provider;
  
  @Component (immediate = true)
  @javax.ws.rs.ext.Provider
  public class MyDummyProvider
  {
      @Context
      protected javax.inject.Provider&lt;ContainerRequestContext&gt; containerRequestContextProvider;
      //The above var is NULL causing calls to fail for this class.
  }
  </code></pre>
  
  <p><strong>My Webservice code</strong>:</p>
  
  <pre><code>@Activate
  public void activate(BundleContext bctx)
  {
      registerServlet(bctx);
      registerDummyResource();
      packages("com.fctest.restful.hello.provider");
      myContainer.reload(this);
  }
  
  private void registerServlet(BundleContext bctx)
  {
      try
      {
          HttpService httpService = bctx.getService(bctx.getServiceReference(HttpService.class));
          Dictionary&lt;String, String&gt; jerseyServletParams = new Hashtable&lt;String, String&gt;();
          jerseyServletParams.put("javax.ws.rs.Application", NoAnnotateRest.class.getName());
          httpService.registerServlet("/services", myContainer, jerseyServletParams, null);
      }
      catch (Exception e)
      {
          LOG.error("Exception occurred registering servlet: ", e);
      }
  }
  
  private void registerDummyResource()
  {
      final Resource.Builder resourceBuilder = Resource.builder();
      resourceBuilder.path("/hello2");
  
      final ResourceMethod.Builder methodBuilder = resourceBuilder.addMethod("GET");
      methodBuilder
              .produces(MediaType.TEXT_PLAIN_TYPE)
              .handledBy(new Inflector&lt;ContainerRequestContext, String&gt;()
              {
                  @Override
                  public String apply(ContainerRequestContext containerRequestContext)
                  {
                      return "Hello World!";
                  }
              });
  
      registerResources(resourceBuilder.build());
  }
  </code></pre>
  
  <p>I also tried below and got the following error:</p>
  
  <pre><code>@Activate
  public void activate(BundleContext bctx)
  {
      registerServlet(bctx);
      registerDummyResource();
      packages("com.fctest.restful.hello.provider");
      register(MyDummyProvider.class);
      myContainer.reload(this);
  }
  </code></pre>
  
  <blockquote>
    <p>2017-06-01 17:03:45,025 | WARN  | raf-3.0.7/deploy | Providers<br>
    | 75 - org.glassfish.jersey.core.jersey-common - 2.17.0 | A provider
    com.fctest.restful.hello.provider.MyDummyProvider registered in SERVER
    runtime does not implement any provider interfaces applicable in the
    SERVER runtime. Due to constraint configuration problems the provider
    com.fctest.restful.hello.provider.MyDummyProvider will be ignored.</p>
  </blockquote>