title: Why am I getting "HTTP Status 404 - Servlet <servlet name> is not available"
body: <p>I am going through <a href="http://static.springsource.org/docs/Spring-MVC-step-by-step/part1.html" rel="nofollow">this Spring web MVC tutorial</a> but am stuck at section 1.12 where I should be seeing a "Hello" page handled by my Controller, but instead get "<strong>HTTP Status 404 - Servlet  is not available</strong>".  I have looked at the other stackoverflow questions that have the same error, but none have helped.</p>
  
  <p>Here are the relevant files:</p>
  
  <p>/web/WEB-INF/<strong>web.xml</strong>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;web-app version="2.4"
           xmlns="http://java.sun.com/xml/ns/j2ee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
       http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" &gt;
  
      &lt;!--
           The "Front Controller" (http://en.wikipedia.org/wiki/Front_Controller_pattern).
           that dispatches requests to registered handlers (Controller implementations).
        --&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;filth&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;filth&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>/web/WEB-INF/<strong>filth-servlet.xml</strong>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:context="http://www.springframework.org/schema/context"
         xsi:schemaLocation="
             http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
             http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
  
      &lt;!-- the application context definition for the filth DispatcherServlet --&gt;
  
      &lt;context:component-scan base-package="com.filth.controller"/&gt;
  
      &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix" value="/web/view/" /&gt;
          &lt;property name="suffix" value=".jsp" /&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>/web/view/<strong>hello.jsp</strong>:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;&lt;title&gt;Hello :: Spring Application&lt;/title&gt;&lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Hello - Spring Application&lt;/h1&gt;
          &lt;p&gt;Greetings.&lt;/p&gt;
       &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>/src/main/java/com/filth/controller/<strong>HelloController.java</strong>:</p>
  
  <pre><code>package com.filth.controller;
  
  import java.io.IOException;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.servlet.ModelAndView;
  
  /**
   * Controller for the "Hello" page
   */
  @Controller
  public class HelloController {
  
      private static final Log LOGGER = LogFactory.getLog(HelloController.class);
  
      @RequestMapping(value="/hello.html", method = RequestMethod.GET)
      public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
  
          LOGGER.info("Returning hello view");
  
          return new ModelAndView("hello");
      }
  
  }
  </code></pre>
  
  <p><strong>/build.properties</strong>:</p>
  
  <pre><code># Ant properties for building FiLTH
  
  appserver.home=${env.WORKSPACE}/tomcat6
  appserver.lib=${appserver.home}/lib
  deploy.path=${appserver.home}/webapps
  
  tomcat.manager.url=http://localhost:8080/manager
  tomcat.manager.username=tomcat
  tomcat.manager.password=s3cret
  </code></pre>
  
  <p><strong>/build.xml</strong>:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  
  &lt;project name="filth" xmlns:ivy="antlib:org.apache.ivy.ant" basedir="." default="usage"&gt;
  
      &lt;taskdef resource="net/sf/antcontrib/antlib.xml"&gt;
          &lt;classpath&gt;
              &lt;pathelement path="${build.lib.dir}/ant-contrib.jar"/&gt;
          &lt;/classpath&gt;
      &lt;/taskdef&gt;
  
      &lt;taskdef name="ivy-configure" classname="org.apache.ivy.ant.IvyConfigure"/&gt;
      &lt;taskdef name="ivy-resolve" classname="org.apache.ivy.ant.IvyResolve"/&gt;
      &lt;taskdef name="ivy-retrieve" classname="org.apache.ivy.ant.IvyRetrieve"/&gt;
      &lt;taskdef name="ivy-deliver" classname="org.apache.ivy.ant.IvyDeliver"/&gt; 
      &lt;taskdef name="ivy-publish" classname="org.apache.ivy.ant.IvyPublish"/&gt;
  
      &lt;target name="ivy-resolve"&gt;
          &lt;ivy:configure /&gt;
  
          &lt;ivy:resolve file="${ivy.dep.file}" conf="${ivy.configurations}" /&gt;
  
          &lt;ivy:retrieve pattern="${ivy.retrieve.pattern}" conf="${ivy.configurations}" /&gt;
          &lt;echo message="ivy.dep.file: ${ivy.dep.file}"/&gt;
          &lt;echo message="ivy.configurations: ${ivy.configurations}"/&gt;
          &lt;echo message="ivy.retrieve.pattern: ${ivy.retrieve.pattern}"/&gt;
      &lt;/target&gt;
  
      &lt;property environment="env"/&gt;
  
      &lt;property file="build.properties"/&gt;
      &lt;property file="build.passwords.properties" /&gt;
  
      &lt;property name="src.dir" value="src/main/java"/&gt;
      &lt;property name="test.dir" value="src/test"/&gt;
      &lt;property name="web.dir" value="web/"/&gt;
      &lt;property name="build.dir" value="target"/&gt;
      &lt;property name="name" value="filth"/&gt;
      &lt;property name="resources.dir" value="src/main/resources"/&gt;
  
      &lt;path id="master-classpath"&gt;
          &lt;fileset dir="lib"&gt;
              &lt;include name="**/*.jar"/&gt;
          &lt;/fileset&gt;
          &lt;!-- We need the servlet API classes: --&gt;
          &lt;!--  * for Tomcat 5/6 use servlet-api.jar --&gt;
          &lt;!--  * for other app servers - check the docs --&gt;
          &lt;fileset dir="${appserver.lib}"&gt;
              &lt;include name="servlet*.jar"/&gt;
          &lt;/fileset&gt;
          &lt;pathelement path="${resources.dir}"/&gt;
          &lt;pathelement path="${build.dir}"/&gt;
      &lt;/path&gt;
  
      &lt;target name="usage"&gt;
          &lt;echo message=""/&gt;
          &lt;echo message="${name} build file"/&gt;
          &lt;echo message="-----------------------------------"/&gt;
          &lt;echo message=""/&gt;
          &lt;echo message="Available targets are:"/&gt;
          &lt;echo message=""/&gt;
          &lt;echo message="build     --&gt; Build the application"/&gt;
          &lt;echo message="deploy    --&gt; Deploy application as directory"/&gt;
          &lt;echo message="deploywar --&gt; Deploy application as a WAR file"/&gt;
          &lt;echo message="install   --&gt; Install application in Tomcat"/&gt;
          &lt;echo message="reload    --&gt; Reload application in Tomcat"/&gt;
          &lt;echo message="start     --&gt; Start Tomcat application"/&gt;
          &lt;echo message="stop      --&gt; Stop Tomcat application"/&gt;
          &lt;echo message="list      --&gt; List Tomcat applications"/&gt;
          &lt;echo message=""/&gt;
      &lt;/target&gt;
  
      &lt;target name="build" description="Compile main source tree java files"&gt;
          &lt;mkdir dir="${build.dir}"/&gt;
          &lt;javac destdir="${build.dir}" source="1.6" target="1.6" debug="true"
                 deprecation="false" optimize="false" failonerror="true"&gt;
              &lt;src path="${src.dir}"/&gt;
              &lt;classpath refid="master-classpath"/&gt;
          &lt;/javac&gt;
      &lt;/target&gt;
  
      &lt;target name="deploy" depends="build" description="Deploy application"&gt;
          &lt;copy todir="${deploy.path}/${name}" preservelastmodified="true"&gt;
              &lt;fileset dir="${web.dir}"&gt;
                  &lt;include name="**/*.*"/&gt;
              &lt;/fileset&gt;
          &lt;/copy&gt;
      &lt;/target&gt;
  
      &lt;target name="deploywar" depends="build" description="Deploy application as a WAR file"&gt;
          &lt;war destfile="${name}.war" webxml="${web.dir}/WEB-INF/web.xml"&gt;
              &lt;fileset dir="${web.dir}"&gt;
                  &lt;include name="**/*.*"/&gt;
              &lt;/fileset&gt;
          &lt;/war&gt;
          &lt;copy todir="${deploy.path}" preservelastmodified="true"&gt;
              &lt;fileset dir="."&gt;
                  &lt;include name="*.war"/&gt;
              &lt;/fileset&gt;
          &lt;/copy&gt;
      &lt;/target&gt;
  
      &lt;target name="buildtests" description="Compile test tree java files"&gt;
          &lt;mkdir dir="${build.dir}"/&gt;
          &lt;javac destdir="${build.dir}" source="1.6" target="1.6" debug="true"
              deprecation="false" optimize="false" failonerror="true"&gt;
              &lt;src path="${test.dir}"/&gt;
              &lt;classpath refid="master-classpath"/&gt;
          &lt;/javac&gt;
      &lt;/target&gt;
  
      &lt;target name="tests" depends="build, buildtests" description="Run tests"&gt;
          &lt;junit printsummary="on"
              fork="false"
              haltonfailure="false"
              failureproperty="tests.failed"
              showoutput="true"&gt;
              &lt;classpath refid="master-classpath"/&gt;
              &lt;formatter type="brief" usefile="false"/&gt;
  
              &lt;batchtest&gt;
                  &lt;fileset dir="${build.dir}"&gt;
                      &lt;include name="**/*Test.*"/&gt;
                  &lt;/fileset&gt;
              &lt;/batchtest&gt;
          &lt;/junit&gt;
  
          &lt;fail if="tests.failed"&gt;
              tests.failed=${tests.failed}
              ***********************************************************
              ***********************************************************
              ****  One or more tests failed!  Check the output ...  ****
              ***********************************************************
              ***********************************************************
          &lt;/fail&gt;
      &lt;/target&gt;
  
  &lt;!-- ============================================================== --&gt;
  &lt;!-- Tomcat tasks - remove these if you don't have Tomcat installed --&gt;
  &lt;!-- ============================================================== --&gt;
  
      &lt;path id="catalina-ant-classpath"&gt;
          &lt;!-- We need the Catalina jars for Tomcat --&gt;
          &lt;!--  * for other app servers - check the docs --&gt;
          &lt;fileset dir="${appserver.lib}"&gt;
             &lt;include name="catalina-ant.jar"/&gt;
             &lt;include name="tomcat-coyote.jar"/&gt;
             &lt;include name="tomcat-util.jar"/&gt;
          &lt;/fileset&gt;
          &lt;fileset dir="${appserver.home}/bin"&gt;
             &lt;include name="tomcat-juli.jar"/&gt;
          &lt;/fileset&gt;
      &lt;/path&gt;
  
      &lt;taskdef name="install" classname="org.apache.catalina.ant.DeployTask"&gt;
          &lt;classpath refid="catalina-ant-classpath"/&gt;
      &lt;/taskdef&gt;
      &lt;taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"&gt;
          &lt;classpath refid="catalina-ant-classpath"/&gt;
      &lt;/taskdef&gt;
      &lt;taskdef name="list" classname="org.apache.catalina.ant.ListTask"&gt;
          &lt;classpath refid="catalina-ant-classpath"/&gt;
      &lt;/taskdef&gt;
      &lt;taskdef name="start" classname="org.apache.catalina.ant.StartTask"&gt;
          &lt;classpath refid="catalina-ant-classpath"/&gt;
      &lt;/taskdef&gt;
      &lt;taskdef name="stop" classname="org.apache.catalina.ant.StopTask"&gt;
          &lt;classpath refid="catalina-ant-classpath"/&gt;
      &lt;/taskdef&gt;
  
      &lt;target name="install" description="Install application in Tomcat"&gt;
          &lt;install url="${tomcat.manager.url}"
                   username="${tomcat.manager.username}"
                   password="${tomcat.manager.password}"
                   path="/${name}"
                   war="${name}"/&gt;
      &lt;/target&gt;
  
      &lt;target name="reload" description="Reload application in Tomcat"&gt;
          &lt;reload url="${tomcat.manager.url}"
                   username="${tomcat.manager.username}"
                   password="${tomcat.manager.password}"
                   path="/${name}"/&gt;
      &lt;/target&gt;
  
      &lt;target name="start" description="Start Tomcat application"&gt;
          &lt;start url="${tomcat.manager.url}"
                   username="${tomcat.manager.username}"
                   password="${tomcat.manager.password}"
                   path="/${name}"/&gt;
      &lt;/target&gt;
  
      &lt;target name="stop" description="Stop Tomcat application"&gt;
          &lt;stop url="${tomcat.manager.url}"
                   username="${tomcat.manager.username}"
                   password="${tomcat.manager.password}"
                   path="/${name}"/&gt;
      &lt;/target&gt;
  
      &lt;target name="list" description="List Tomcat applications"&gt;
          &lt;list url="${tomcat.manager.url}"
                   username="${tomcat.manager.username}"
                   password="${tomcat.manager.password}"/&gt;
      &lt;/target&gt;
  
  &lt;!-- End Tomcat tasks --&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>/ivy.xml</strong>:</p>
  
  <pre><code>&lt;ivy-module version="2.0"&gt;
      &lt;info organisation="org.apache" module="hello-ivy"/&gt;
      &lt;dependencies&gt;
          &lt;dependency org="org.springframework" name="spring-context" rev="4.1.6.RELEASE"/&gt;
          &lt;dependency org="org.springframework" name="spring-webmvc" rev="4.1.6.RELEASE"/&gt;
          &lt;dependency org="commons-logging" name="commons-logging" rev="1.2"/&gt;
          &lt;dependency org="javax.servlet" name="servlet-api" rev="2.5"/&gt;
          &lt;dependency org="junit" name="junit" rev="4.12"/&gt;
      &lt;/dependencies&gt;
  &lt;/ivy-module&gt;
  </code></pre>
  
  <p>I am getting the error when navigating to <a href="http://localhost:8080/filth/hello.html" rel="nofollow">http://localhost:8080/filth/hello.html</a>.
  catalina.out does not give any errors, and I do see the log entry from HelloController.java, but very inconsistently--not sure why that is either.</p>
  
  <p>Note that <a href="http://localhost:8080/filth/index.jsp" rel="nofollow">http://localhost:8080/filth/index.jsp</a>, and <a href="http://localhost:8080/filth/view/hello.jsp" rel="nofollow">http://localhost:8080/filth/view/hello.jsp</a> work--just going through the Controller is not working as expected.</p>
  
  <p>Anyone have any ideas?
  Let me know if you need more context/info.
  Thanks!</p>