title: Tomcat java.lang.NoClassDefFoundError: javax/servlet/Filter when trying to publish a Struts2 Dynamic Web App
body: <p>I have seen people asked a similar question but not exactly the same, and the suggested solutions I have seen did not really work for me.</p>
  
  <p><strong>My current issue</strong>
  My tomcat prints out the following log message containing exception as long as there is a Struts 2 web app published. 
  And I can load the right page for localhost:8080 but not the web app, even though the war folder is already placed inside the webapps folder of Tomcat.</p>
  
  <p>I guess it's related to the servlet-api.jar, but I have made sure that jar is inside the Tomcat lib folder, and that Tomcat folder is being pointed by my Eclipse Tomcat server.</p>
  
  <p>I am using Mac OSX and I am also sure my env variables are in place. By typing export in the terminal, I can see the value of CATALINA_BASE, CATALINA_HOME, CLASSPATH etc.</p>
  
  <p>So I need help..</p>
  
  <p>Server message:</p>
  
  <pre><code>Nov 28, 2013 1:59:57 PM org.apache.catalina.core.AprLifecycleListener init
  INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
  Nov 28, 2013 1:59:57 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
  WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:HellowWorldStruts2' did not find a matching property.
  Nov 28, 2013 1:59:58 PM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["http-bio-8080"]
  Nov 28, 2013 1:59:58 PM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
  Nov 28, 2013 1:59:58 PM org.apache.catalina.startup.Catalina load
  INFO: Initialization processed in 659 ms
  Nov 28, 2013 1:59:58 PM org.apache.catalina.core.StandardService startInternal
  INFO: Starting service Catalina
  Nov 28, 2013 1:59:58 PM org.apache.catalina.core.StandardEngine startInternal
  INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
  Nov 28, 2013 2:00:01 PM org.apache.tomcat.websocket.server.WsSci onStartup
  INFO: JSR 356 WebSocket (Java WebSocket 1.0) support is not available when running on Java 6. To suppress this message, run Tomcat on Java 7, remove the WebSocket JARs from $CATALINA_HOME/lib or add the WebSocketJARs to the tomcat.util.scan.DefaultJarScanner.jarsToSkip property in $CATALINA_BASE/conf/catalina.properties. Note that the deprecated Tomcat 7 WebSocket API will be available. 
  Nov 28, 2013 2:00:01 PM org.apache.catalina.core.StandardContext filterStart
  SEVERE: Exception starting filter struts2
  java.lang.NoClassDefFoundError: javax/servlet/Filter
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
      at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1617)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
      at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
      at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
      at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:142)
      at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
      at org.apache.catalina.core.ApplicationFilterConfig.&lt;init&gt;(ApplicationFilterConfig.java:107)
      at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:680)
  Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      ... 31 more
  Nov 28, 2013 2:00:01 PM org.apache.catalina.core.StandardContext startInternal
  SEVERE: Error filterStart
  Nov 28, 2013 2:00:01 PM org.apache.catalina.core.StandardContext startInternal
  SEVERE: Context [/HellowWorldStruts2] startup failed due to previous errors
  Nov 28, 2013 2:00:01 PM org.apache.catalina.startup.HostConfig deployDirectory
  INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/docs
  Nov 28, 2013 2:00:01 PM org.apache.catalina.startup.HostConfig deployDirectory
  INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/examples
  Nov 28, 2013 2:00:02 PM org.apache.catalina.core.ApplicationContext log
  INFO: ContextListener: contextInitialized()
  Nov 28, 2013 2:00:02 PM org.apache.catalina.core.ApplicationContext log
  INFO: SessionListener: contextInitialized()
  Nov 28, 2013 2:00:02 PM org.apache.catalina.core.ApplicationContext log
  INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@37e80c87')
  Nov 28, 2013 2:00:02 PM org.apache.catalina.startup.HostConfig deployDirectory
  INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/host-manager
  Nov 28, 2013 2:00:02 PM org.apache.catalina.startup.HostConfig deployDirectory
  INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/manager
  Nov 28, 2013 2:00:02 PM org.apache.catalina.startup.HostConfig deployDirectory
  INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/ROOT
  Nov 28, 2013 2:00:02 PM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["http-bio-8080"]
  Nov 28, 2013 2:00:02 PM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["ajp-bio-8009"]
  Nov 28, 2013 2:00:02 PM org.apache.catalina.startup.Catalina start
  INFO: Server startup in 4323 ms
  </code></pre>
  
  <p>Solution: I found out I copied my entire Struts2 jar library to my /Library/Java/Extensions folder. I remove all those jars, and this error is gone (new error..)</p>