title: Could not load user defined filter in web.xml: com.xxx.CORSFilter
body: <p>I have a SpringBoot application running on WebLogic Server Version: 12.2.1.3.0
  When I define a custom servlet Filter its working fine on Embedded Tomcat. However, when i deploy my application as a war file to wlserver it throws following error after each request. What am i missing here? </p>
  
  <pre><code>    &lt;Could not load user defined filter in web.xml: com.thy.bwsadmin.CORSFilter.
  java.lang.AbstractMethodError
      at weblogic.servlet.internal.FilterManager$FilterInitAction.run(FilterManager.java:400)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:328)
      at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197)
      at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)
      at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)
      at weblogic.servlet.internal.FilterManager.initFilter(FilterManager.java:130)
      at weblogic.servlet.internal.FilterManager.loadFilter(FilterManager.java:92)
      at weblogic.servlet.internal.FilterManager.preloadFilters(FilterManager.java:72)
      at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1928)
      at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3106)
      at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1843)
      at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:884)
      at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:360)
      at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:356)
      at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
      at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:138)
      at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
      at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233)
      at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228)
      at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
      at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:78)
      at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:52)
      at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:752)
      at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
      at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:262)
  </code></pre>
  
  <p>This is the content of my web.xml file</p>
  
  <pre><code>&lt;web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
            http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      version="3.0"&gt;
  
      &lt;display-name&gt;MWSAdminService&lt;/display-name&gt;
  
      &lt;filter&gt;
          &lt;filter-name&gt;CORSFilter&lt;/filter-name&gt;
          &lt;filter-class&gt;com.sample.CORSFilter&lt;/filter-class&gt;
      &lt;/filter&gt;
  
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;CORSFilter&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>I am setting servlet dependency as provided to prevent jar conflicts.</p>
  
  <pre><code>        &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>This is my Filter class.  </p>
  
  <pre><code>import java.io.IOException;
  import javax.servlet.Filter;
  import javax.servlet.FilterChain;
  import javax.servlet.ServletException;
  import javax.servlet.ServletRequest;
  import javax.servlet.ServletResponse;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.core.Ordered;
  import org.springframework.core.annotation.Order;
  import org.springframework.stereotype.Component;
  import com.thy.bwsadmin.service.SecurityUserService;
  
      @Component
      @Order(Ordered.HIGHEST_PRECEDENCE)
      public class CORSFilter implements Filter {
  
  
  
          @Autowired
          SecurityUserService securityUserService;
  
          @Override
          public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
                  throws IOException, ServletException {
  
              HttpServletResponse response = (HttpServletResponse) res;
              HttpServletRequest request = (HttpServletRequest) req;
  
              boolean isAuthenticated = authenticateUser(request.getHeader("identity_no"), request.getRequestURI());
  
  
              if (isAuthenticated) {
                  if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
                      response.setStatus(HttpServletResponse.SC_OK);
                  } else {
                      chain.doFilter(req, res);
                  }
              } else {
                  response.sendError(HttpServletResponse.SC_OK, "401");
              }
  
          }
  
          private boolean authenticateUser(String userId, String requestURI) {
              if (Util.isNotEmpty(userId) 
              &amp;&amp;  securityUserService.isAuthorizedForEndpoint(userId.trim(), requestURI)) {
                  return true;
              }else{
                  return false;
              }
  
          }
  
      }
  </code></pre>
  
  <p>As a solution i tried to remove the filter definitions in web.xml file and registered my filter as a bean configuration since this is a SpringBoot application. I also removed @Component and @Order annotations from my filter. 
  But the result was the same as above. It is still working on Tomcat but not in Weblogic. Here is the code for filter config bean.</p>
  
  <pre><code>@Configuration
  public class Filters {
  
      @Bean
      public FilterRegistrationBean&lt;CORSFilter&gt; loggingFilter() {
          FilterRegistrationBean&lt;CORSFilter&gt; registrationBean = new FilterRegistrationBean&lt;&gt;();
          registrationBean.setFilter(new CORSFilter());
          registrationBean.addUrlPatterns("/*");
          return registrationBean;
      }
  }
  </code></pre>