My Oracle Support Banner

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

Last updated on OCTOBER 19, 2018

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

To view full details, sign in with your My Oracle Support account.

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


In this Document
Symptoms
Cause
Solution
References


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.