title: Cannot inject HttpServletRequest in ContainerRequestFilter via @Context jersey2.x and weblogic 12.1.3
body: <p>I was not able to inject HttpServletRequest in ContainerRequestFilter via @Context in Jersey 2.22.1 using weblogic 12.1.3. I researched several places that this issue exists and in many places I see that it is fixed in Jersey 2.4, but I am still seeing this issue. My implementation and code is attached. Please let me know if I am missing anything. </p>
  
  <p>AuthFilter</p>
  
  <pre><code>@Provider
  @Priority(Priorities.AUTHENTICATION)
  public class AuthFilter implements ContainerRequestFilter {
      @Context
      HttpServletRequest webRequest;
  
      @Context
      HttpServletResponse webResponse;
  
      @Override
      public void filter(ContainerRequestContext requestContext) throws IOException {
          final HttpSession session = webRequest.getSession();
          final String userName = (String)session.getAttribute("USER_NAME");
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;servlet&gt;
          &lt;servlet-name&gt;jersey-application&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;
          &lt;init-param&gt;
                    &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
                    &lt;param-value&gt; xyz.xyz.xyz.xyz.xyz.resource&lt;/param-value&gt;
                &lt;/init-param&gt;
  
      &lt;/servlet&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;authentication-servlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;xyz.xyz.xyz.xyz.xyz.xyz.AuthenticationServlet&lt;/servlet-class&gt;
  
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;jersey-application&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/jaxrs/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>Pom.xml</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
      &lt;artifactId&gt;jersey-container-servlet-core&lt;/artifactId&gt;
      &lt;version&gt;2.22.1&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
      &lt;artifactId&gt;jersey-media-moxy&lt;/artifactId&gt;
      &lt;version&gt;2.22.1&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.ext&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-spring3&lt;/artifactId&gt;
          &lt;version&gt;2.22.1&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
                  &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;artifactId&gt;
                      jersey-container-servlet-core
                  &lt;/artifactId&gt;
                  &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;artifactId&gt;hk2&lt;/artifactId&gt;
                  &lt;groupId&gt;org.glassfish.hk2&lt;/groupId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>Weblogic.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app"&gt;
       &lt;library-ref&gt;
           &lt;library-name&gt;jax-rs&lt;/library-name&gt;
           &lt;specification-version&gt;2.0&lt;/specification-version&gt;
           &lt;implementation-version&gt;2.5.1&lt;/implementation-version&gt;
      &lt;/library-ref&gt;
      &lt;container-descriptor&gt;
      &lt;prefer-application-packages&gt;
          &lt;!-- jsr311 --&gt;
          &lt;package-name&gt;javax.ws.rs.*&lt;/package-name&gt;
          &lt;!-- javassist --&gt;
          &lt;package-name&gt;javassist.*&lt;/package-name&gt;
          &lt;!-- aop repackaged --&gt;
          &lt;package-name&gt;org.aopalliance.*&lt;/package-name&gt;
  
          &lt;!-- jersey 2 --&gt;
          &lt;package-name&gt;jersey.repackaged.*&lt;/package-name&gt;
          &lt;package-name&gt;org.glassfish.jersey.*&lt;/package-name&gt;
          &lt;package-name&gt;com.sun.research.ws.wadl.*&lt;/package-name&gt;
  
          &lt;!-- hk2 --&gt;
          &lt;package-name&gt;org.glassfish.hk2.*&lt;/package-name&gt;
          &lt;package-name&gt;org.jvnet.hk2.*&lt;/package-name&gt;
          &lt;package-name&gt;org.jvnet.tiger_types.*&lt;/package-name&gt;
      &lt;/prefer-application-packages&gt;
          &lt;show-archived-real-path-enabled&gt;true&lt;/show-archived-real-path-enabled&gt;
          &lt;resource-reload-check-secs&gt;0&lt;/resource-reload-check-secs&gt;
      &lt;/container-descriptor&gt;
      &lt;context-root&gt;XYZ&lt;/context-root&gt;
  
  &lt;/weblogic-web-app&gt;
  </code></pre>
  
  <p>And the error I see is below</p>
  
  <pre><code>Root cause of ServletException.
  A MultiException has 4 exceptions.  They are:
  1. java.lang.IllegalArgumentException: interface org.glassfish.hk2.api.ProxyCtl is not visible from class loader
  2. java.lang.IllegalArgumentException: While attempting to create a Proxy for javax.servlet.http.HttpServletRequest in scope org.glassfish.jersey.process.internal.RequestScoped an error occured while creating the proxy
  3. java.lang.IllegalArgumentException: While attempting to resolve the dependencies of xyz.xyz.xyz.xyz.xyz.xyz.xyz.AuthFilter errors were found
  4. java.lang.IllegalStateException: Unable to perform operation: resolve on xyz.xyz.xyz.xyz.xyz.xyz.xyz.AuthFilter
  
      at org.jvnet.hk2.internal.Collector.throwIfErrors(Collector.java:89)
      at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:249)
      at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:357)
      at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:471)
  </code></pre>
  
  <p><strong>Please let me know in case of any workaround for this issue.</strong></p>