Filter.init(FilterConfig) Not Called When Registered During ServletContainerInitializer.onStartup (Doc ID 1582644.1)

Last updated on JUNE 09, 2016

Applies to:

Oracle Weblogic Server - Version 12.1.1.0 and later
Information in this document applies to any platform.

Symptoms

On WLS 12.1.1 when following the servlet 3.0 method for registering filters during the ServletContainerInitializer.onStartup(c, ctx) method, the filter gets registered, but the Filter.init(FilterConfig) method is never called.

For example we would expect to see this sent to stdout:

Initializing myServlet
Initializing myFilter
filterConfig = weblogic.servlet.internal.????
filterConfig.getServletContext() = ServletContext@672337408[app:servlet3bug2-1.0-SNAPSHOT module:servlet3bug2-1.0-SNAPSHOT.war path:/servlet3bug2 spec-version:3.0]
myFilter.doFilter
servletConfig = weblogic.servlet.internal.ServletStubImpl@6ee0405f - myServlet class: 'com.abc.test.servlet3bug.MyServlet'
servletConfig.getServletContext() = ServletContext@672337408[app:servlet3bug2-1.0-SNAPSHOT module:servlet3bug2-1.0-SNAPSHOT.war path:/servlet3bug2 spec-version:3.0]
MyServlet.doGet

But what we actually get is this:

Initializing myServlet
Initializing myFilter
myFilter.doFilter
servletConfig = weblogic.servlet.internal.ServletStubImpl@6ee0405f - myServlet class: 'com.abc.test.servlet3bug.MyServlet'
servletConfig.getServletContext() = ServletContext@672337408[app:servlet3bug2-1.0-SNAPSHOT module:servlet3bug2-1.0-SNAPSHOT.war path:/servlet3bug2 spec-version:3.0]
MyServlet.doGet


Notice that the filterConfig lines are never printed, indicating that MyFilter.init(FilterConfig) is never called.

Below is snippet of code

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms