title: "No adapter for handler" while configuring Spring MVC app
body: <p>I started to follow this tutorial <a href="http://docs.spring.io/docs/Spring-MVC-step-by-step/part1.html" rel="nofollow noreferrer">http://docs.spring.io/docs/Spring-MVC-step-by-step/part1.html</a>.</p>
  
  <p>I created the dummy HelloController and defined the bean in webapp-servlet.xml:</p>
  
  <pre><code>&lt;bean name="/hello.htm" class="com.planner.HelloController"&gt;&lt;/bean&gt;
  </code></pre>
  
  <p>But when I try to access
      /planner/hello.htm 
  I see:</p>
  
  <pre><code>HTTP Status 500 - No adapter for handler [com.planner.HelloController@187cd18]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler
  </code></pre>
  
  <p>I found similar question here <a href="https://stackoverflow.com/questions/3896013/no-adapter-for-handler-exception">No adapter for handler exception</a>. They tried using the annotation driven mapping together with the BeanNameUrlHandlerMapping and got similar exception. The solution was to add the SimpleControllerHandlerAdapter bean to the spring context, but in my case it didn't help (should not be neccessary though, as BeanNameUrlHandlerMapping should be the default mapping anyway, right?). I also added the BeanNameUrlHandlerMapping bean just in case, but it's still the same.</p>
  
  <p>Below is my configuration:</p>
  
  <p>planner-servlet.xml
      </p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&gt;
  
      &lt;bean name="/hello.htm" class="com.planner.HelloController"&gt;&lt;/bean&gt;
  
      &lt;bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/&gt; 
  &lt;bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>web.xml
      </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-file&gt;
          index.jsp
      &lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;planner&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;planner&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.htm&lt;/url-pattern&gt;     
  &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>HelloController.java:</p>
  
  <pre><code>package com.planner;
  
  import java.io.IOException;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.servlet.ModelAndView;
  
  public class HelloController {
  
      protected final Logger logger = LoggerFactory.getLogger(getClass());
  
      public ModelAndView handleRequest(HttpServletRequest request,
          HttpServletResponse response) throws ServletException, IOException {
  
          logger.info("Returning hello view");
  
          //default view resolver will just forward to this url
          return new ModelAndView("hello.jsp");
      }       
  }
  </code></pre>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  
  &lt;groupId&gt;com.planner&lt;/groupId&gt;
  &lt;artifactId&gt;Planner&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
  &lt;packaging&gt;war&lt;/packaging&gt;
  
  &lt;properties&gt;
      &lt;java.version&gt;1.7&lt;/java.version&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
      &lt;javax.annotation.version&gt;1.0&lt;/javax.annotation.version&gt;
      &lt;spring-framework.version&gt;3.2.3.RELEASE&lt;/spring-framework.version&gt; 
      &lt;!-- &lt;spring-framework.version&gt;3.0.0.RELEASE&lt;/spring-framework.version&gt; --&gt;
      &lt;hibernate.version&gt;4.2.1.Final&lt;/hibernate.version&gt;
      &lt;logback.version&gt;1.0.13&lt;/logback.version&gt;
      &lt;slf4j.version&gt;1.7.5&lt;/slf4j.version&gt;
      &lt;junit.version&gt;4.10&lt;/junit.version&gt;
      &lt;javax.servlet.version&gt;2.5&lt;/javax.servlet.version&gt;      
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
  
      &lt;!-- JSR-250 --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.annotation&lt;/groupId&gt;
          &lt;artifactId&gt;jsr250-api&lt;/artifactId&gt;
          &lt;version&gt;${javax.annotation.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;version&gt;${spring-framework.version}&lt;/version&gt;
      &lt;/dependency&gt; 
  
      &lt;!-- Logging with SLF4J &amp; LogBack --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
          &lt;version&gt;${slf4j.version}&lt;/version&gt;
          &lt;scope&gt;compile&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Test Artifacts --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
          &lt;version&gt;${spring-framework.version}&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;${junit.version}&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt; 
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
          &lt;version&gt;${javax.servlet.version}&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;         
      &lt;/dependency&gt; 
  
  &lt;/dependencies&gt;
  </code></pre>
  
  <p></p>
  
  <p>Please help :) I am apparently missing something :)</p>