title: No adapter for handler ... The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler
body: <p>Tired of using XML files for Spring config, tried moving into a full Java approach, but I'm doubtlessly failing at it.</p>
  
  <p>Just 2 classes involved:</p>
  
  <pre><code>@Configuration
  public class AppInitializer implements WebApplicationInitializer {
  
      @Override
      public void onStartup(ServletContext servletContext) throws ServletException {
          WebApplicationContext context = getContext();
          servletContext.addListener(new ContextLoaderListener(context));
          DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
          dispatcherServlet.setDetectAllHandlerAdapters(true);
          ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet", dispatcherServlet);
          dispatcher.setLoadOnStartup(1);
          dispatcher.addMapping("/");
      }
  
      private AnnotationConfigWebApplicationContext getContext() {
          AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
          context.setConfigLocation("cl.waypoint.ecobox");
          return context;
      }
  
      @Bean
      public RequestMappingHandlerAdapter annotationMethodHandlerAdapter() {
          final RequestMappingHandlerAdapter annotationMethodHandlerAdapter = new RequestMappingHandlerAdapter();
          List&lt;HttpMessageConverter&lt;?&gt;&gt; httpMessageConverters = new ArrayList&lt;&gt;();
          httpMessageConverters.add(new MappingJackson2HttpMessageConverter());
          annotationMethodHandlerAdapter.setMessageConverters(httpMessageConverters);
          return annotationMethodHandlerAdapter;
      }
  }
  </code></pre>
  
  <p>And the Controller:</p>
  
  <pre><code>@Controller
  public class Loader {
  
      private static final Logger LOGGER = Logger.getLogger("Loader");
  
      @RequestMapping("/routeLoader")
      public LoaderResult load(@RequestBody byte[] data) {
          LOGGER.info("new Route!");
          return new LoaderResult();
      }
  
  }
  </code></pre>
  
  <p>And a "beautiful" red wave (Stacktrace) when using cUrl to POST some JSON data to the endpoint:</p>
  
  <pre><code>javax.servlet.ServletException: No adapter for handler [cl.waypoint.ecobox.Loader@2c4d0325]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler
      at org.springframework.web.servlet.DispatcherServlet.getHandlerAdapter(DispatcherServlet.java:1173)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
      at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1527)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1484)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Thread.java:722)
  </code></pre>
  
  <p>Tomcat's startup log:</p>
  
  <pre><code>Información: Initializing Spring root WebApplicationContext
  nov 02, 2016 12:40:57 PM org.springframework.web.context.ContextLoader initWebApplicationContext
  Información: Root WebApplicationContext: initialization started
  nov 02, 2016 12:40:57 PM org.springframework.web.context.support.AnnotationConfigWebApplicationContext prepareRefresh
  Información: Refreshing Root WebApplicationContext: startup date [Wed Nov 02 12:40:57 ART 2016]; root of context hierarchy
  nov 02, 2016 12:40:57 PM org.springframework.web.context.support.AnnotationConfigWebApplicationContext loadBeanDefinitions
  Información: Found 2 annotated classes in package [cl.waypoint.ecobox]
  nov 02, 2016 12:40:58 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
  Información: Looking for @ControllerAdvice: Root WebApplicationContext: startup date [Wed Nov 02 12:40:57 ART 2016]; root of context hierarchy
  nov 02, 2016 12:40:59 PM org.springframework.web.context.ContextLoader initWebApplicationContext
  Información: Root WebApplicationContext: initialization completed in 1469 ms
  nov 02, 2016 12:40:59 PM org.apache.catalina.core.ApplicationContext log
  Información: Initializing Spring FrameworkServlet 'DispatcherServlet'
  nov 02, 2016 12:40:59 PM org.springframework.web.servlet.DispatcherServlet initServletBean
  Información: FrameworkServlet 'DispatcherServlet': initialization started
  nov 02, 2016 12:40:59 PM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
  Información: Mapped URL path [/routeLoader] onto handler 'loader'
  nov 02, 2016 12:40:59 PM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
  Información: Mapped URL path [/routeLoader.*] onto handler 'loader'
  nov 02, 2016 12:40:59 PM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
  Información: Mapped URL path [/routeLoader/] onto handler 'loader'
  nov 02, 2016 12:40:59 PM org.springframework.web.servlet.DispatcherServlet initServletBean
  Información: FrameworkServlet 'DispatcherServlet': initialization completed in 152 ms
  </code></pre>
  
  <p>Related Maven dependencies:</p>
  
  <pre><code>    &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
              &lt;version&gt;4.3.3.RELEASE&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;4.3.3.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
              &lt;version&gt;2.8.4&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  </code></pre>
  
  <p>Test invoker:</p>
  
  <pre><code>curl --request POST -H "Content-Type: application/json" -d '{  "NroViaje": 1,  "CodDestino": "678",  "DescDestino": "VILLA ALEMANA",  "PatenteCamion": "AA1111",  "PatenteTrailer": "BB2222",  "FechaEntrega": "2016-10-31"}' http://localhost:8080/ecobox-load-route/routeLoader
  </code></pre>
  
  <p><a href="https://drive.google.com/open?id=0B6vDWUpvj99NQ1NDN0ZnWHRqQUE" rel="nofollow noreferrer">Sample sources and pom file</a></p>
  
  <p>What could be missing?</p>
  
  <p>PS: found at least 4 alike questions within Stackoverflow community, but unfortunately none of them were helpful :(</p>