I've got a pretty simple authentication filter that is giving me grief.
public class AuthenticationFilter implements Filter
{
public void init(FilterConfig config) throws ServletException
{
this.config = config;
}
public void doFilter(ServletRequest req, SerlvetResponse res, FilterChain chain)
{
// bunch of code that I'm sure is okay
// several paths lead to a RequestDispatcher redirect
// if authentication succeeds, this executes:
chain.doFilter(req, res);
}
public void destroy()
{
config = null;
}
}
When execution gets to chain.doFilter(req, res), I get a Null Pointer Exception every time. I've tried outputting the null status of the variables chain, req, and res right before doFilter is called -- they're definitely non-null. I've tried replacing chain.doFilter(req, res) with another RequestDispatcher redirect -- it works with no problem. I even did a "chain instanceof FilterChain" check to make sure nothing crazy was going on.
So chain isn't null; req isn't null; res isn't null; but chain.doFilter(req, res) gives me a NPE. What gives? I hope it's something simple and obvious that I should already know.
My web.xml entry looks like this:
<filter>
<filter-name>authenticationFilter</filter-name>
<filter-class>com.wsec.blue.AuthenticationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>authenticationFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
That's how it ought to be, right?