title: Getting HTTP 404 Error in Eclipse project
body: <p>I'm trying to learn how to run a Spring MVC project on a server (still very new at this), and I'm getting an http 404 error.. I'm using Eclipse Luna 4.4.1, Java 7, Spring 4.1.4 and Pivotal tc server 3.0.2 on a Windows 7 machine. Before I go further, let me say that I get the same 404 error when creating a simple practice project using Tomcat 7, so I think the problem is somewhere in my configuration of the servers (both in tc server and in Tomcat). Here is a screenshot showing my project directory, the servers I've tried running, and the error page: <img src="https://i.stack.imgur.com/JM2yY.png" alt="enter image description here"></p>
  
  <p>The program code seems fine. When I run my HomeControllerTest (which I've basically gotten from the new 4th edition of Spring in Action by Craig Walls), it compiles and passes. Where else do I need to look to troubleshoot this problem? 
  `
      package com.kwalker.practicewellness;</p>
  
  <pre><code>import org.junit.Test;
  import org.springframework.test.web.servlet.MockMvc;
  import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
  import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
  import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
  
  import com.kwalker.practicewellness.web.HomeController;
  
  public class HomeControllerTest {
  
  @Test
  public void testHomePage() throws Exception {
      HomeController controller = new HomeController();
      MockMvc mockMvc = standaloneSetup(controller).build();
  
      mockMvc.perform(get("/")).andExpect(view().name("home"));
  
  }
  
  }
  </code></pre>
  
  <p>`
  Here is the HomeController class:</p>
  
  <pre><code>package com.kwalker.practicewellness.web;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  
  @Controller
  public class HomeController {
  
  @RequestMapping(value="/", method=RequestMethod.GET)
  public String home() {
      return "home";
  }
  }
  </code></pre>
  
  <p>Here is the WellnessWebAppInitializer:</p>
  
  <pre><code>package com.kwalker.practicewellness.config;
  
  import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
  
  public class WellnessWebAppInitializer extends
      AbstractAnnotationConfigDispatcherServletInitializer {
  
  @Override
  protected Class&lt;?&gt;[] getRootConfigClasses() {
      return new Class&lt;?&gt;[] { RootConfig.class };
  }
  
  @Override
  protected Class&lt;?&gt;[] getServletConfigClasses() {
      return new Class&lt;?&gt;[] { WebConfig.class };
  }
  
  @Override
  protected String[] getServletMappings() {
      return new String[] { "/" };
  }
  
  }
  </code></pre>
  
  <p>Here is the RootConfig:</p>
  
  <pre><code>package com.kwalker.practicewellness.config;
  
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.ComponentScan.Filter;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.context.annotation.FilterType;
  import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  
  @Configuration
  @ComponentScan(basePackages={"practicewellness"}, 
              excludeFilters={@Filter(type=FilterType.ANNOTATION, value=EnableWebMvc.class)})
  public class RootConfig {
  
  }
  </code></pre>
  
  <p>Here is WebConfig:</p>
  
  <pre><code>package com.kwalker.practicewellness.config;
  
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.web.servlet.ViewResolver;
  import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
  import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
  import org.springframework.web.servlet.view.InternalResourceViewResolver;
  
  @Configuration
  @EnableWebMvc
  @ComponentScan("practicewellness.web")
  public class WebConfig extends WebMvcConfigurerAdapter {
  
  @Bean
  public ViewResolver viewResolver() {
      InternalResourceViewResolver resolver = new InternalResourceViewResolver();
      resolver.setPrefix("/WEB-INF/views/");
      resolver.setSuffix(".jsp");
      resolver.setExposeContextBeansAsAttributes(true);
      return resolver;
  }
  
  @Override
  public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
      configurer.enable();
  }
  
  }
  </code></pre>
  
  <p>Here is the home.jsp page:</p>
  
  <pre><code>&lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;
  &lt;%@ page session="false" %&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Welcome&lt;/title&gt;
  &lt;link rel="stylesheet"
          type="text/css"
          href="&lt;c:url value="/resources/style.css"/&gt;"&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;
  Welcome to Vital Potential!  
  &lt;/h1&gt;
  
  &lt;P&gt;  The time on the server is ${serverTime}. &lt;/P&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is the output from Maven build:</p>
  
  <pre><code>[INFO] Scanning for projects...
  [INFO] 
  [INFO] Using the builder    org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
  [INFO]                                                                         
  [INFO] ------------------------------------------------------------------------
  [INFO] Building Practice Wellness 1.0.0-BUILD-SNAPSHOT
  [INFO] ------------------------------------------------------------------------
  [INFO] 
  [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ practicewellness ---
  [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
  [INFO] Copying 1 resource
  [INFO] 
  [INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ practicewellness ---
  [INFO] Nothing to compile - all classes are up to date
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD SUCCESS
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 1.954 s
  [INFO] Finished at: 2015-01-04T10:37:59-07:00
  [INFO] Final Memory: 8M/115M
  [INFO] ------------------------------------------------------------------------
  </code></pre>
  
  <p>Here is the output on the Console: (only one WARNING, and it's the same warning they get on the training video I'm watching, which runs fine for them):</p>
  
  <pre><code>Jan 04, 2015 10:42:37 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
  WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to  'org.eclipse.jst.jee.server:Practice Wellness' did not find a matching property.
  Jan 04, 2015 10:42:37 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Server version:        Apache Tomcat/7.0.57
  Jan 04, 2015 10:42:37 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Server built:          Nov 3 2014 08:39:16 UTC
  Jan 04, 2015 10:42:37 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Server number:         7.0.57.0
  Jan 04, 2015 10:42:37 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: OS Name:               Windows 7
  Jan 04, 2015 10:42:37 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: OS Version:            6.1
  Jan 04, 2015 10:42:37 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Architecture:          amd64
  Jan 04, 2015 10:42:37 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: JAVA_HOME:             C:\Program Files\Java\jdk1.7.0_71\jre
  Jan 04, 2015 10:42:37 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: JVM Version:           1.7.0_71-b14
  Jan 04, 2015 10:42:37 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: JVM Vendor:            Oracle Corporation
  Jan 04, 2015 10:42:37 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: CATALINA_BASE:            C:\Users\kyle\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2
  Jan 04, 2015 10:42:37 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: CATALINA_HOME:         C:\Apache-Tomcat\apache-tomcat-7.0.57
  Jan 04, 2015 10:42:37 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Command line argument: -    Dcatalina.base=C:\Users\kyle\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2
  Jan 04, 2015 10:42:37 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Command line argument: -Dcatalina.home=C:\Apache-Tomcat\apache-tomcat-7.0.57
  Jan 04, 2015 10:42:37 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Command line argument: - Dwtp.deploy=C:\Users\kyle\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps
  Jan 04, 2015 10:42:37 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Command line argument: -Djava.endorsed.dirs=C:\Apache-Tomcat\apache-tomcat-7.0.57\endorsed
  Jan 04, 2015 10:42:37 AM org.apache.catalina.startup.VersionLoggerListener log
  INFO: Command line argument: -Dfile.encoding=Cp1252
  Jan 04, 2015 10:42:37 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
  INFO: The APR based Apache Tomcat Native library which allows optimal performance in production  environments was not found on the java.library.path: C:\Program   Files\Java\jdk1.7.0_71\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Orac le\Java\javapath;C:\Program Files (x86)\HP SimplePass 2011\x64;C:\Program Files (x86)\HP SimplePass  2011\;;C:\Program Files\Broadcom\Broadcom 802.11\Driver;;C:\Program Files\Common Files\Microsoft   Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows  Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common  Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio  Shared\12.0\DLLShared\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\WIDCOMM\Bluetooth  Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program  Files\Broadcom\WHL\;C:\Program Files\Broadcom\WHL\syswow64;C:\Program  Files\Broadcom\WHL\SysWow64\;C:\Program Files\Broadcom\WHL\SysWow64\syswow64;C:\Program Files  (x86)\Intel\Services\IPT\;C:\Program Files\Java\jdk1.8.0_25\bin;C:\Program Files\Gradle\Gradle- 2.0\gradle-2.2.1\bin;.
  Jan 04, 2015 10:42:37 AM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["http-bio-8080"]
  Jan 04, 2015 10:42:37 AM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
  Jan 04, 2015 10:42:37 AM org.apache.catalina.startup.Catalina load
  INFO: Initialization processed in 911 ms
  Jan 04, 2015 10:42:38 AM org.apache.catalina.core.StandardService startInternal
  INFO: Starting service Catalina
  Jan 04, 2015 10:42:38 AM org.apache.catalina.core.StandardEngine startInternal
  INFO: Starting Servlet Engine: Apache Tomcat/7.0.57
  Jan 04, 2015 10:42:40 AM org.apache.catalina.core.ApplicationContext log
  INFO: Spring WebApplicationInitializers detected on classpath:  [com.kwalker.practicewellness.config.WellnessWebAppInitializer@4eda480b]
  Jan 04, 2015 10:42:40 AM org.apache.catalina.core.ApplicationContext log
  INFO: Initializing Spring root WebApplicationContext
  INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization  started
  INFO : org.springframework.web.context.support.AnnotationConfigWebApplicationContext - Refreshing  Root WebApplicationContext: startup date [Sun Jan 04 10:42:40 MST 2015]; root of context hierarchy
  INFO : org.springframework.web.context.support.AnnotationConfigWebApplicationContext - Registering annotated classes: [class com.kwalker.practicewellness.config.RootConfig]
   INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
  INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 524 ms
  INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization started
  Jan 04, 2015 10:42:41 AM org.apache.catalina.core.ApplicationContext log
  INFO: Initializing Spring FrameworkServlet 'dispatcher'
  INFO : org.springframework.web.context.support.AnnotationConfigWebApplicationContext - Refreshing  WebApplicationContext for namespace 'dispatcher-servlet': startup date [Sun Jan 04 10:42:41 MST  2015]; parent: Root WebApplicationContext
  INFO : org.springframework.web.context.support.AnnotationConfigWebApplicationContext - Registering annotated classes: [class com.kwalker.practicewellness.config.WebConfig]
  INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
  INFO : org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/**]  onto handler of type [class  org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler]
  INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter -  Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date   [Sun Jan 04 10:42:41 MST 2015]; parent: Root WebApplicationContext
  INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization completed in 1029 ms
  Jan 04, 2015 10:42:42 AM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["http-bio-8080"]
  Jan 04, 2015 10:42:42 AM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["ajp-bio-8009"]
  Jan 04, 2015 10:42:42 AM org.apache.catalina.startup.Catalina start
  INFO: Server startup in 4348 ms
  </code></pre>