title: Deployed war file on tomcat gives 404 error
body: <p>I have successfully deployed my war file of a small web application using an ant <code>build.xml</code> file to my local tomcat 7.0.42 server. When I type in the url to my application, <code>localhost:8080/springapp/index.jsp</code>, I get a 404 error.  I don't understand why I get an error when the war file is deployed.</p>
  
  <p>I know my deployment is successful because I can see the <code>/springapp</code> listed in the tomcat manager app, <code>localhost:8080/manager</code>.  I have been following this tutorial, <a href="http://docs.spring.io/docs/Spring-MVC-step-by-step/part1.html" rel="nofollow">http://docs.spring.io/docs/Spring-MVC-step-by-step/part1.html</a>, almost exactly besides altering a few things because I am using tomcat 7 and it is using tomcat 6. I am currently on step 1.4.
  Any help would be much appreciated, I've been stuck on this problem for over a day of googling and troubleshooting.</p>
  
  <p>Here is my build.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;project name="springapp" basedir="." default="usage"&gt;
      &lt;property file="build.properties"/&gt;
  
      &lt;property name="src.dir" value="src"/&gt;
      &lt;property name="web.dir" value="war"/&gt;
      &lt;property name="build.dir" value="${web.dir}/WEB-INF/classes"/&gt;
      &lt;property name="name" value="springapp"/&gt;
  
      &lt;path id="master-classpath"&gt;
          &lt;fileset dir="${web.dir}/WEB-INF/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="${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.5" target="1.5" 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;path id="catalina-ant-classpath"&gt;
          &lt;fileset dir="${appserver.home}/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;/project&gt;
  </code></pre>
  
  <p>Here is my web.xml file:</p>
  
  <pre><code>&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;welcome-file-list&gt;
              &lt;welcome&gt;
                  index.jsp
              &lt;/welcome&gt;
          &lt;/welcome-file-list&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Here is my properties.build file:</p>
  
  <pre><code>appserver.home=/Users/joe/projects/tomcat
  appserver.lib=${appserver.home}/lib
  
  deploy.path=${appserver.home}/webapps
  
  tomcat.manager.url=http://localhost:8080/manager/text
  tomcat.manager.username=someone
  tomcat.manager.password=something
  </code></pre>
  
  <p>Here is my tomcat-users.xml file:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;tomcat-users&gt;
      &lt;role rolename="manager-gui"/&gt;
      &lt;role rolename="manager-script"/&gt;
      &lt;role rolename="manager-jmx"/&gt;
      &lt;role rolename="manager-status"/&gt;
      &lt;user username="someone" password="something" 
            roles="manager-gui,manager-script,manager-jmx,manager-status"/&gt;
  &lt;/tomcat-users&gt;
  </code></pre>