0

I have been developing a project with dropwizard-guicey, Rignt now I'm setting up a security project and they have something like this:

@Provider
public class CorsFilter implements ContainerResponseFilter{

    @Context
    private HttpServletRequest httpServletRequest;

    @Override
    public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
        throws IOException {
        this.httpServletRequest.getAttributeNames();
}



}

They are getting a null pointer exception, is there any way I could make this work?

Daniel F Jaramillo
  • 225
  • 1
  • 4
  • 11
  • How are you registering it? – Paul Samsotha Jun 28 '17 at 16:51
  • If you're registering it as instance, try registering it as a class. – Paul Samsotha Jun 28 '17 at 17:00
  • I believe we answered that in your bug report. Guice has no idea about context, this is a different eco system. At creation time of the Filter singleton, there is no request to be injected. You need to inject a provider for the request, so that guice can resolve this variable at request time. – pandaadb Jun 29 '17 at 10:48

0 Answers0