users@grizzly.java.net

Error with Grizzly when using Spring DelegatingFilterProxy

From: Ed Anuff <ed_at_anuff.com>
Date: Thu, 22 Sep 2011 17:29:01 -0700

I've got a fairly simple Grizzly setup that's using Spring and Jersey
and I'm seeing an error message on startup.

If I add the following code:

                Map<String, String> initParameters = new HashMap<String, String>();
                initParameters.put("targetFilterLifecycle", "true");
                adapter.addFilter(
                                new org.springframework.web.filter.DelegatingFilterProxy(),
                                "shiroFilter", initParameters);


I get this error message:

java.lang.IllegalArgumentException: ServletContext must not be null
        at org.springframework.util.Assert.notNull(Assert.java:112)
        at org.springframework.web.context.support.WebApplicationContextUtils.getWebApplicationContext(WebApplicationContextUtils.java:111)
        at org.springframework.web.context.support.WebApplicationContextUtils.getWebApplicationContext(WebApplicationContextUtils.java:101)
        at org.springframework.web.filter.DelegatingFilterProxy.findWebApplicationContext(DelegatingFilterProxy.java:307)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:249)
        at com.sun.grizzly.http.servlet.FilterChainImpl.doFilter(FilterChainImpl.java:158)
        at com.sun.grizzly.http.servlet.FilterChainImpl.invokeFilterChain(FilterChainImpl.java:123)
        at com.sun.grizzly.http.servlet.ServletAdapter.service(ServletAdapter.java:249)
        at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:147)

Is there something I'm doing wrong? If I get rid of the filter, it
seems to work ok, but I need the filter for my app.

Thanks

Ed