Spring MVC - DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler


This is full exception thrown from the server.

javax.servlet.ServletException: No adapter for handler [Class name]     
The DispatcherServlet configuration needs to include a HandlerAdapter 
that supports this handler

Problem Overview

This is took me a while to figure this out with lot of readings in Spring docs.

In Spring MVC when there is a need to map request -> Handler objects we need to have Handler Mapping interface implmented.

This is in org.springframework.web.servlet as Spring uses servlet technology under the hood.

In the dispatcher-servlet you can have any handler mapping implemented.

But by default with dispatcher-servlet, BeanNameUrlHandletMapping and DefaultAnnotationHandlerMapping is included.

See for more details.


Solution

Since BeanNameUrlHandletMapping comes in default you dont need to override it again in the dispatcher.
If you have done it, simply remove and it works fine. And worked for me. :D 

PS

Since Spring 3.1 they have removed DefaultAnnotationHandlerMapping 
and introduced RequestMappingHandlerMapping






Share:

0 comments: