Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject HttpServletRequest in ContainerRequestFilter for Jersey #211

Closed
sapessi opened this issue Nov 13, 2018 · 2 comments
Closed

Inject HttpServletRequest in ContainerRequestFilter for Jersey #211

sapessi opened this issue Nov 13, 2018 · 2 comments
Assignees
Labels
Milestone

Comments

@sapessi
Copy link
Collaborator

sapessi commented Nov 13, 2018

  • Framework version: 1.2
  • Implementations: Jersey

Scenario

Trying to inject an HttpServletRequest object in a container request filter results in an exception:

public class MyJaxRsFilter implements ContainerRequestFilter {
	
	@Context HttpServletRequest request;

	public void filter(ContainerRequestContext ctx) throws IOException {
    	      System.out.println("Hello JAXRS filter, request = " + request);
	}

}

Expected behavior

HttpServletRequest should be injected corectly

Actual behavior

Throws java.lang.IllegalStateException: Not inside a request scope

@sapessi sapessi self-assigned this Nov 13, 2018
@sapessi sapessi added the bug label Nov 13, 2018
@sapessi sapessi added this to the Release 1.3 milestone Nov 13, 2018
sapessi added a commit that referenced this issue Dec 20, 2018
…pliers to allow injection in a request scope. Addresses issue #211
@sapessi
Copy link
Collaborator Author

sapessi commented Dec 20, 2018

@martinpllu the fix for this is now in the core branch. It will go out with 1.3. The root cause of the issue is that Jersey (and the JAX-RS specs) treat suppliers as singletons so by default it does not allow injection in single-request-scoped contexts. I have added the configuration to allow "proxying" of the suppliers.

@sapessi
Copy link
Collaborator Author

sapessi commented Dec 26, 2018

Resolving in preparation for 1.3 release

@sapessi sapessi closed this as completed Dec 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant