title: Tomcat SEVERE: Exception starting filter CorsFilter, ClassNotFoundException
body: <p>I'm trying to enable CORS for my java servlet with the following class:</p>
  
  <pre><code>package com.prosperity.mobile.core;
  
  import java.io.IOException;
  
  import javax.servlet.Filter;
  import javax.servlet.FilterChain;
  import javax.servlet.FilterConfig;
  import javax.servlet.ServletException;
  import javax.servlet.ServletRequest;
  import javax.servlet.ServletResponse;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  public class CORSFilter implements Filter {
  
      @Override
      public void init(FilterConfig filterConfig) throws ServletException {
      }
  
      public void doFilter(ServletRequest servletRequest,
              ServletResponse servletResponse, FilterChain chain)
              throws IOException, ServletException {
          HttpServletRequest request = (HttpServletRequest) servletRequest;
          // System.out.println("Request: " + request.getMethod());
  
          HttpServletResponse resp = (HttpServletResponse) servletResponse;
          resp.addHeader("Access-Control-Allow-Origin", "*");
          resp.addHeader("Access-Control-Allow-Methods", "GET,POST");
          resp.addHeader("Access-Control-Allow-Headers",
                  "Origin, X-Requested-With, Content-Type, Accept");
  
          // Just ACCEPT and REPLY OK if OPTIONS
          if (request.getMethod().equals("OPTIONS")) {
              resp.setStatus(HttpServletResponse.SC_OK);
              return;
          }
          chain.doFilter(request, servletResponse);
      }
  
      @Override
      public void destroy() {
      }
  }
  </code></pre>
  
  <p>My XML:</p>
  
  <pre><code>&lt;filter&gt;    
      &lt;filter-name&gt;CorsFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;com.prosperity.mobile.core.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;
  </code></pre>
  
  <p>And when I try and deploy the war to the tomcat instance:</p>
  
  <pre><code>SEVERE: Exception starting filter CorsFilter
  java.lang.ClassNotFoundException: com.prosperity.mobile.core.CORSFilter
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
      at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:529)
      at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:511)
      at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:139)
      at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
      at org.apache.catalina.core.ApplicationFilterConfig.&lt;init&gt;(ApplicationFilterConfig.java:105)
      at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4809)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
      at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
      at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
      at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
      at java.util.concurrent.FutureTask.run(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
  
  Sep 21, 2015 11:49:35 AM org.apache.catalina.core.StandardContext startInternal
  SEVERE: Error filterStart
  Sep 21, 2015 11:49:35 AM org.apache.catalina.core.StandardContext startInternal
  SEVERE: Context [/ProsperityMobile] startup failed due to previous errors
  </code></pre>
  
  <p>Which seems like a pretty obvious error, it's complaining that it's not finding the CORSFilter class.. but it's there, in the correct package and everything?!</p>
  
  <p>As a note: My tomcat instance is located at: C:\apache-tomcat-7.0.52</p>