title: DispatcherServlet noHandlerFound
body: <p>I have been building an application using Spring MVC 4/hibernate 4 and Web flow 2.4 with Java configuration.  I have the services and daos built and tested with JUnits, but get no where with adding the WebFlow components to the app. </p>
  
  <p>I moved the controller into the core package along with CoreContextConfiguration and get no where. The LoginController has a corresponding login.jsp in the WEB-INF/flows with a login-flow.xml
  I would prefer that Spring Webflow handles the controllers and I can show more of the configuration code as needed.  I know I am missing something and could use a fresh set of eyes on this.  </p>
  
  <pre><code>@EnableWebMvc//added
  @Configuration
  @Import({
      ServiceConfiguration.class, 
      FlowConfiguration.class,
      WebMVCConfiguration.class,
      DAOConfiguration.class
  })
  @ComponentScan("org.tigersndragons.salonbooks.model")
  public class CoreContextConfiguration {
  
  INFO: Server startup in 12640 ms
  Jun 02, 2014 3:14:43 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
  WARNING: No mapping found for HTTP request with URI [/salonbooks/login] in DispatcherServlet with name 'salonbooks'
  </code></pre>
  
  <p>I am getting the above error when trying to access the app from </p>
  
  <pre><code>localhost:8080/salonbooks/login
  </code></pre>
  
  <p>If I explicitly import LoginController to the CoreConfiguration, I get</p>
  
  <pre><code>javax.servlet.ServletException: No adapter for handler [org.tigersndragons.salonbooks.core.LoginController@20bd9af4]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler
  </code></pre>
  
  <p>Below is controller snippet</p>
  
  <p>-- updated to Remove the controller from configuration</p>
  
  <pre><code>@Controller
  public class LoginController extends AbstractController{
      @Autowired
      LoginActionFlows loginActionFlows;
  
      @RequestMapping(value="/login", method=RequestMethod.GET)
      public String showLogin(Model model){
          model.addAttribute("employee", new Employee());
          return "login";//new ModelAndView("index","employee", model);
      }
  
      @RequestMapping(value="/", method=RequestMethod.GET)
      public String index(Model model){
  
          return showLogin( model);//new ModelAndView("index","employee", model);
      }
  </code></pre>
  
  <p>The web.xml looks like</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns="http://java.sun.com/xml/ns/javaee"
           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
           id="WebApp_ID" version="2.5"&gt;    
      &lt;display-name&gt;SalonBooks&lt;/display-name&gt;        
      &lt;context-param&gt;
          &lt;param-name&gt;contextClass&lt;/param-name&gt;
          &lt;param-value&gt;org.springframework.web.context.support.AnnotationConfigWebApplicationContext&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;org.tigersndragons.salonbooks.core.CoreContextConfiguration&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;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;salonbooks&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;contextClass&lt;/param-name&gt;
              &lt;param-value&gt;org.springframework.web.context.support.AnnotationConfigWebApplicationContext&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;salonbooks&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;    
  &lt;/web-app&gt;
  </code></pre>
  
  <p>--</p>
  
  <p>FlowConfiguration</p>
  
  <pre><code>@Configuration
  public class FlowConfiguration extends AbstractFlowConfiguration{
  
  @Autowired 
  WebMVCConfiguration webMVCConfiguration;
  
  @Bean
  public FlowExecutor flowExecutor() {
      return getFlowExecutorBuilder(flowRegistry())
              .build();
  }
  
  @Bean 
  public FlowController flowController (){
      FlowController flowController = new FlowController();
      flowController.setFlowExecutor(flowExecutor());
                  flowController.setFlowHandlerAdapter(webMVCConfiguration.flowHandlerAdapter());
      return flowController;
  }
  
  //updated flowRegistry to specify the specific flow files
  @Bean
  public FlowDefinitionRegistry flowRegistry() {
      return getFlowDefinitionRegistryBuilder(flowBuilderServices())
              //.setBasePath("/WEB-INF/flows")
              //.addFlowLocationPattern("/**/*-flow.xml")
              .addFlowLocation("/WEB-INF/flows/login-flow.xml","login")
              .addFlowLocation("/WEB-INF/flows/home/home-flow.xml","home")
              .addFlowLocation("/WEB-INF/flows/person/person-flow.xml","person")
              .addFlowLocation("/WEB-INF/flows/appointment/appointment-flow.xml","appointment")
              .addFlowLocation("/WEB-INF/flows/order/order-flow.xml","order")
              .build();
  }
  
  @Bean
  public FlowBuilderServices flowBuilderServices() {
      return getFlowBuilderServicesBuilder()
              .setViewFactoryCreator(mvcViewFactoryCreator())
              .setValidator(validator())
              .setDevelopmentMode(true)
              .build();
  }
  
  @Bean
  public MvcViewFactoryCreator mvcViewFactoryCreator() {
      MvcViewFactoryCreator factoryCreator = new MvcViewFactoryCreator();
      factoryCreator.setDefaultViewSuffix(".jsp");
      factoryCreator.setViewResolvers(Arrays.&lt;ViewResolver&gt;asList(webMVCConfiguration.viewResolver()));
      factoryCreator.setUseSpringBeanBinding(true);
      return factoryCreator;
  }
  
  @Bean
  public LocalValidatorFactoryBean validator() {
      return new LocalValidatorFactoryBean();
  }
  </code></pre>
  
  <p>WebMVCConfiguration</p>
  
  <pre><code>@Configuration
  public class WebMVCConfiguration extends WebMvcConfigurerAdapter {
  
  @Autowired
  private FlowConfiguration webFlowConfig;
  /*  updated this by commenting out
  @Bean 
  public ControllerClassNameHandlerMapping controllerClassNameHandlerMapping(){
      ControllerClassNameHandlerMapping mapping  =  new ControllerClassNameHandlerMapping();
       mapping.setPathPrefix("/flows");
      return mapping;
  }
  */
  
  @Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
      registry.addResourceHandler("/resources/**").addResourceLocations("/", "classpath:/META-INF/web-resources/");
  }
  
  @Override
  public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
      configurer.enable();
  }
  
  @Override
  public void addViewControllers(ViewControllerRegistry registry) {
  // updated this method to do nothing    
  //      registry.addViewController("/");
  //      registry.addViewController("/login");
  //      registry.addViewController("/home");
  //      registry.addViewController("/person");
  }
  
  @Bean
  public FlowHandlerMapping flowHandlerMapping() {
      FlowHandlerMapping handlerMapping = new FlowHandlerMapping();
      handlerMapping.setOrder(-1);
      handlerMapping.setFlowRegistry(webFlowConfig.flowRegistry());
      return handlerMapping;
  }
  
  @Bean
  public FlowHandlerAdapter flowHandlerAdapter() {
      FlowHandlerAdapter handlerAdapter = new FlowHandlerAdapter();
      handlerAdapter.setFlowExecutor(webFlowConfig.flowExecutor());
      handlerAdapter.setSaveOutputToFlashScopeOnRedirect(true);
      return handlerAdapter;
  }
  
  @Bean
  public SalonFlowHandler SalonFlowHandler() {
      return new SalonFlowHandler();
  }
  
  /*added urlMappings*/
  
  @Bean 
  public SimpleUrlHandlerMapping urlMappings(){
      SimpleUrlHandlerMapping simpleUrlHandlerMapping = new SimpleUrlHandlerMapping();
      Properties urlProperties = new Properties();
      urlProperties.put("/*", webFlowConfig.flowController());
      urlProperties.put("/login", webFlowConfig.flowController());
      urlProperties.put("/home", webFlowConfig.flowController());
      urlProperties.put("/person", webFlowConfig.flowController());
      urlProperties.put("/appointment", webFlowConfig.flowController());
      urlProperties.put("/order", webFlowConfig.flowController());
      simpleUrlHandlerMapping.setMappings(urlProperties);
      simpleUrlHandlerMapping.setAlwaysUseFullPath(true);
      return simpleUrlHandlerMapping;
  }
  
  @Bean
  public ViewResolver viewResolver() {
      InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
      viewResolver.setPrefix("/WEB-INF/flows/");
      viewResolver.setSuffix(".jsp");
      return viewResolver;
  }
  </code></pre>
  
  <p>login.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;
  &lt;%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %&gt;
  &lt;%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;Welcome to SalonBooks&lt;/title&gt;
  &lt;/head&gt; 
  &lt;body&gt;
  &lt;div&gt;Welcome to SalonBooks!!&lt;/div&gt;
  
      &lt;form:form id="login" model="loginActionFlows" 
      action="${flowExecutionUrl}" &gt;
      &lt;input type="hidden" name ="_flowExecutionKey"
      value="${flowExecutionKey}" /&gt;
      User: &lt;br/&gt;&lt;form:input type="text" path="username" /&gt;&lt;br/&gt;
      Passcode: &lt;br/&gt;&lt;form:input type="password" path="password"/&gt;&lt;br/&gt;
       &lt;input name="_eventId_doLogin" type="submit" value="Login"/&gt; | 
       &lt;input type="button" name="_eventId_cancel" value="Cancel" /&gt;
      &lt;/form:form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>login-flow.xml updated to specify view and model </p>
  
  <pre><code>&lt;flow xmlns="http://www.springframework.org/schema/webflow"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/webflow 
    http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"
     start-state="login"&gt;
  &lt;var name="loginActionFlows" class="org.tigersndragons.salonbooks.model.flows.LoginActionFlows"/&gt;
  
  &lt;view-state id="login" view="login" model="loginActionFlows"&gt;
  
      &lt;transition on="doLogin" to="verifylogin" /&gt;
      &lt;transition on="cancel" to="done" /&gt;
  &lt;/view-state&gt;
  
  &lt;action-state id="verifylogin"&gt;
      &lt;evaluate result ="employee" expression="loginActionFlows.checkEmployee(requestParameters.username, requestParameters.password)"/&gt;
  
      &lt;transition to ="home" /&gt;
  &lt;/action-state&gt;
  
  &lt;subflow-state id="home" subflow="home-flow"&gt;
      &lt;transition to="finish" /&gt;
  &lt;/subflow-state&gt;
  
  &lt;end-state id="finish"/&gt;
  
  &lt;/flow&gt;
  </code></pre>
  
  <p>This now simply produces a a dry /text rendition of the login.jsp instead of rendering as html. So it appears to start the flow, but the rendering is missing. </p>
  
  <p><img src="https://i.stack.imgur.com/i7i8D.jpg" alt="enter image description here"></p>