title: JAVA Spring MVC - HTTP status 404 - RequestMapping isn't working
body: <p>I began to learn Spring MVC and I have a problem with my app. When I type: "<a href="http://localhost:8080/addcat" rel="nofollow">http://localhost:8080/addcat</a>" in my browser, it returns 404 status.</p>
  
  <p>web.xml:</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;mvc-dispatcher&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/applicationContext.xml&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;mvc-dispatcher&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/applicationContext.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  </code></pre>
  
  <p>applicationContext.xml</p>
  
  <pre><code>    &lt;context:annotation-config /&gt;
      &lt;context:component-scan base-package="application, dao, model, controllers" /&gt;
      &lt;mvc:default-servlet-handler /&gt;
  
      &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix"&gt;
              &lt;value&gt;/WEB-INF/views/&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="suffix"&gt;
              &lt;value&gt;.jsp&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>@Controller
  public class CatController {
  
      @Autowired
      private CatDAO catDao;
  
      @RequestMapping("/")
      public String Index() {
          return "index";
      }
  
      @RequestMapping(value="/addcat", method = RequestMethod.GET)
      public String addCat(Model model) {
          return "addCat";
      }
  
  }
  </code></pre>
  
  <p>I work on Tomcat v7.0. Routing isn't working for any option - for "/" also. </p>
  
  <p>EDIT:
  After few changes, I have logs from Tomcat:</p>
  
  <pre><code>paź 04, 2015 10:28:19 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: C:\Program Files\Java\jre1.8.0_51\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_51/bin/server;C:/Program Files/Java/jre1.8.0_51/bin;C:/Program Files/Java/jre1.8.0_51/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Lenovo\Bluetooth Software\;C:\Program Files\Lenovo\Bluetooth Software\syswow64;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\sts-bundle\sts-3.7.0.RELEASE;;.
  paź 04, 2015 10:28:19 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
  WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:kotki-webapp' did not find a matching property.
  paź 04, 2015 10:28:20 PM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["http-bio-8080"]
  paź 04, 2015 10:28:20 PM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
  paź 04, 2015 10:28:20 PM org.apache.catalina.startup.Catalina load
  INFO: Initialization processed in 1037 ms
  paź 04, 2015 10:28:20 PM org.apache.catalina.core.StandardService startInternal
  INFO: Starting service Catalina
  paź 04, 2015 10:28:20 PM org.apache.catalina.core.StandardEngine startInternal
  INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
  paź 04, 2015 10:28:22 PM org.apache.catalina.core.ApplicationContext log
  INFO: No Spring WebApplicationInitializer types detected on classpath
  paź 04, 2015 10:28:22 PM org.apache.catalina.core.ApplicationContext log
  INFO: Initializing Spring root WebApplicationContext
  paź 04, 2015 10:28:22 PM org.springframework.web.context.ContextLoader initWebApplicationContext
  INFO: Root WebApplicationContext: initialization started
  paź 04, 2015 10:28:23 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
  INFO: Refreshing Root WebApplicationContext: startup date [Sun Oct 04 22:28:23 CEST 2015]; root of context hierarchy
  paź 04, 2015 10:28:23 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
  INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
  paź 04, 2015 10:28:23 PM org.springframework.web.context.support.XmlWebApplicationContext refresh
  WARNING: Exception encountered during context initialization - cancelling refresh attempt
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'kotyController' defined in file [C:\Users\Maciej\Java\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\kotki-webapp\WEB-INF\classes\controllers\KotyController.class]: Post-processing failed of bean type [class controllers.KotyController] failed; nested exception is java.lang.IllegalStateException: Failed to introspect bean class [controllers.KotyController] for resource metadata: could not find class that it depends on
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:940)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
      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.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)
  Caused by: java.lang.IllegalStateException: Failed to introspect bean class [controllers.KotyController] for resource metadata: could not find class that it depends on
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:334)
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:287)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:935)
      ... 21 more
  Caused by: java.lang.NoClassDefFoundError: Ldao/KotDAO;
      at java.lang.Class.getDeclaredFields0(Native Method)
      at java.lang.Class.privateGetDeclaredFields(Unknown Source)
      at java.lang.Class.getDeclaredFields(Unknown Source)
      at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:707)
      at org.springframework.util.ReflectionUtils.doWithLocalFields(ReflectionUtils.java:649)
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.buildResourceMetadata(CommonAnnotationBeanPostProcessor.java:351)
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:330)
      ... 23 more
  Caused by: java.lang.ClassNotFoundException: dao.KotDAO
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
      ... 30 more
  
  paź 04, 2015 10:28:23 PM org.springframework.web.context.ContextLoader initWebApplicationContext
  SEVERE: Context initialization failed
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'kotyController' defined in file [C:\Users\Maciej\Java\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\kotki-webapp\WEB-INF\classes\controllers\KotyController.class]: Post-processing failed of bean type [class controllers.KotyController] failed; nested exception is java.lang.IllegalStateException: Failed to introspect bean class [controllers.KotyController] for resource metadata: could not find class that it depends on
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:940)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
      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.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)
  Caused by: java.lang.IllegalStateException: Failed to introspect bean class [controllers.KotyController] for resource metadata: could not find class that it depends on
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:334)
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:287)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:935)
      ... 21 more
  Caused by: java.lang.NoClassDefFoundError: Ldao/KotDAO;
      at java.lang.Class.getDeclaredFields0(Native Method)
      at java.lang.Class.privateGetDeclaredFields(Unknown Source)
      at java.lang.Class.getDeclaredFields(Unknown Source)
      at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:707)
      at org.springframework.util.ReflectionUtils.doWithLocalFields(ReflectionUtils.java:649)
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.buildResourceMetadata(CommonAnnotationBeanPostProcessor.java:351)
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:330)
      ... 23 more
  Caused by: java.lang.ClassNotFoundException: dao.KotDAO
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
      ... 30 more
  
  paź 04, 2015 10:28:23 PM org.apache.catalina.core.StandardContext listenerStart
  SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'kotyController' defined in file [C:\Users\Maciej\Java\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\kotki-webapp\WEB-INF\classes\controllers\KotyController.class]: Post-processing failed of bean type [class controllers.KotyController] failed; nested exception is java.lang.IllegalStateException: Failed to introspect bean class [controllers.KotyController] for resource metadata: could not find class that it depends on
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:940)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
      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.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)
  Caused by: java.lang.IllegalStateException: Failed to introspect bean class [controllers.KotyController] for resource metadata: could not find class that it depends on
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:334)
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:287)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:935)
      ... 21 more
  Caused by: java.lang.NoClassDefFoundError: Ldao/KotDAO;
      at java.lang.Class.getDeclaredFields0(Native Method)
      at java.lang.Class.privateGetDeclaredFields(Unknown Source)
      at java.lang.Class.getDeclaredFields(Unknown Source)
      at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:707)
      at org.springframework.util.ReflectionUtils.doWithLocalFields(ReflectionUtils.java:649)
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.buildResourceMetadata(CommonAnnotationBeanPostProcessor.java:351)
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:330)
      ... 23 more
  Caused by: java.lang.ClassNotFoundException: dao.KotDAO
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
      ... 30 more
  
  paź 04, 2015 10:28:23 PM org.apache.catalina.core.StandardContext startInternal
  SEVERE: Error listenerStart
  paź 04, 2015 10:28:23 PM org.apache.catalina.core.StandardContext startInternal
  SEVERE: Context [/kotki-webapp] startup failed due to previous errors
  paź 04, 2015 10:28:23 PM org.apache.catalina.core.ApplicationContext log
  INFO: Closing Spring root WebApplicationContext
  paź 04, 2015 10:28:24 PM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["http-bio-8080"]
  paź 04, 2015 10:28:24 PM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["ajp-bio-8009"]
  paź 04, 2015 10:28:24 PM org.apache.catalina.startup.Catalina start
  INFO: Server startup in 3906 ms
  </code></pre>
  
  <p><strong>My catalogue structure: <a href="http://postimg.org/image/whqpqckpn/" rel="nofollow">http://postimg.org/image/whqpqckpn/</a></strong></p>