title: How to register a provider in Jersey 1.x via ResourceConfig?
body: <p>As <code>com.sun.jersey.api.core.ResourceConfig</code> doesn't contain '<code>register</code>' method.</p>
  
  <p>I want to register <code>ContainerResponseFilter</code> programmatically.</p>
  
  <p>I also tried to register it via <code>@Provider</code> annotation:</p>
  
  <pre><code>@Provider
  public class MyFilter implements ContainerRequestFilter, ContainerResponseFilter {
      @Override
      public ContainerRequest filter(ContainerRequest containerRequest) {
  
          return containerRequest;
      }
      @Override
      public ContainerResponse filter(ContainerRequest containerRequest, ContainerResponse containerResponse) {
  
          return containerResponse;
      }
  }
  </code></pre>
  
  <p>But it's not triggered.</p>
  
  <p>Update:</p>
  
  <p>In web.xml:</p>
  
  <pre><code> &lt;init-param&gt;
              &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
              &lt;param-value&gt;rest.providers&lt;/param-value&gt;
    &lt;/init-param&gt;
  </code></pre>
  
  <p>In server's log I see:</p>
  
  <blockquote>
    <p>com.sun.jersey.api.core.ScanningResourceConfig init     INFO: No
    provider classes found.</p>
  </blockquote>
  
  <p>Update2:<br>
  Added class:</p>
  
  <pre><code>public class MyApplication  extends ResourceConfig{
  
  
      public MyApplication(){
          getProviderClasses().add(LoggingFilter.class);
      }
  </code></pre>
  
  <p>constructor was not triggered.</p>
  
  <p>In server Log I see:</p>
  
  <pre><code>Mar 28, 2018 3:46:47 PM com.sun.jersey.api.core.PackagesResourceConfig init
  INFO: Scanning for root resource and provider classes in the packages:
    rest.services
  Mar 28, 2018 3:46:47 PM com.sun.jersey.api.core.ScanningResourceConfig logClasses
  INFO: Root resource classes found:
    class rest.services.RestRes1
  Mar 28, 2018 3:46:47 PM com.sun.jersey.api.core.ScanningResourceConfig init
  INFO: No provider classes found.
  Mar 28, 2018 3:46:47 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
  INFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17 AM'
  </code></pre>
  
  <p>it only finds package with resources but not providers.</p>
  
  <p>Update 3:</p>
  
  <p>If I explicitly define my provider class in web.xml,</p>
  
  <pre><code>  &lt;init-param&gt;
          &lt;param-name&gt;com.sun.jersey.spi.container.ContainerRequestFilters&lt;/param-name&gt;
          &lt;param-value&gt;rest.services.MyFilter&lt;/param-value&gt;
    &lt;/init-param&gt;
  </code></pre>
  
  <p>It works fine.</p>
  
  <p>But I need to do it programmatically. </p>