Giter Site home page Giter Site logo

@Context annotation declaration of HttpServletReqeuest object in parent reference is passing the first time API hit values to the resource always about jersey HOT 3 OPEN

Ganeshfair avatar Ganeshfair commented on July 18, 2024
@Context annotation declaration of HttpServletReqeuest object in parent reference is passing the first time API hit values to the resource always

from jersey.

Comments (3)

jansupol avatar jansupol commented on July 18, 2024

This issue looks tricky. While it can be a Jersey issue, I'd like to exclude possibilities that come from the Specific JBoss environment.

  • HttpServletRequest can be provided by multiple sources. One of them is one of the CDI/Weld jars that provides a CDI bean for the HttpServletRequest. Since @Inject is used, the CDI can be the injector instead of Jersey. Jersey supplies HttpServletRequest only by org.glassfish.jersey.containers:jersey-container-servlet-core. Do you have it in your environment?

  • Jersey supplies the HttpServletRequest provided by the servlet container, it does not have its own implementation, so from the actual injected instance it won't be clear whose bean is injected

  • From the intermittent nature of this issue it might be that sometimes there is some other provider than usual.

  • Jersey sets the HttpServletRequest in Request Scope so your issue should not apply from the quick look at the code.

  • When you change @Inject to @Context, does it help?

from jersey.

Ganeshfair avatar Ganeshfair commented on July 18, 2024

@jansupol Thanks for the response... PFB my clarifications on this issue.

  1. Yes, we have org.glassfish.jersey.containers:jersey-container-servlet-core in our library path. Also HttpServletRequest is part of javax.servlet:javax.servlet-api and tomcat.servlet-api jars, I believe jersey uses the javax.servlet-api for injecting.

  2. Not tried modifying the @Inject to @context as the file this Inject done is a common file for all our APIs, so don't want to touch that point. But added the local variables for http servlet and response in the ActualResourceFile.class as below, after that the issue is not observed yet and keep monitoring.
    @context HttpServletRequest request;
    @context HttpServletResponse response;

  3. But wanted to understand how jersey injects and sets the scope of request processing context, also the actual cause of the issue that why the first API hit request context is always used. Is there Appserver level dependency, we using Jboss.

Thanks in advance... !!!

from jersey.

jansupol avatar jansupol commented on July 18, 2024

You can observe Jersey setting the supplier for injection in the WebComponent class.

from jersey.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.