Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

FilterChain.doFilter causes NullPointerException?

843841Mar 8 2004 — edited Mar 11 2004
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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 8 2004
Added on Mar 8 2004
4 comments
9,005 views