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
As an alternative to typically preferred injection by @Context
, @Inject
, or @Autowire
, you can inject HttpServletRequest into a request-scoped bean using Spring's static method:
HttpServletRequest request=
((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
Note that this approach is not ideal, because static methods make your code harder to test and make your code more rigid.