org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public java.lang.String com.playonsports.event.controller.EventController.create(com.playonsports.event.bean.Event,org.springframework.validation.BindingResult,javax.servlet.http.HttpServletResponse,org.springframework.ui.Model) throws org.springframework.validation.BindException]; nested exception is java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature!

Spring JIRA | Nick Padgett | 7 years ago
  1. 0

    Instead of using a command/form object, I bind much of my data to the request body. I expected that I could specify an Errors/BindingResult object after a @RequestBody method parameter. Currently, I do the following: {code} @RequestMapping(value = "/events", method = RequestMethod.POST) public String create(@RequestBody final Event event, final HttpServletResponse response, final Model model) throws BindException { final BindingResult result = new BeanPropertyBindingResult(event, ""); ValidationUtils.invokeValidator(this.eventValidator, event, result); if (result.hasErrors()) { throw new BindException(result); } ... } {code} I would like to do the following: {code} @RequestMapping(value = "/events", method = RequestMethod.POST) public String create(@RequestBody final Event event, final BindingResult result, final HttpServletResponse response, final Model model) throws BindException { ValidationUtils.invokeValidator(this.eventValidator, event, result); if (result.hasErrors()) { throw new BindException(result); } ... } {code} However, when I do, I receive the following exception: {code} 2010-04-21 09:48:09,014 [http-8080-2] WARN org.springframework.web.servlet.handler.SimpleMappingExceptionResolver - Handler execution resulted in exception org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public java.lang.String com.playonsports.event.controller.EventController.create(com.playonsports.event.bean.Event,org.springframework.validation.BindingResult,javax.servlet.http.HttpServletResponse,org.springframework.ui.Model) throws org.springframework.validation.BindException]; nested exception is java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature! at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716) ... Caused by: java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature! at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:264) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:163) ... 54 more {code}

    Spring JIRA | 7 years ago | Nick Padgett
    org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public java.lang.String com.playonsports.event.controller.EventController.create(com.playonsports.event.bean.Event,org.springframework.validation.BindingResult,javax.servlet.http.HttpServletResponse,org.springframework.ui.Model) throws org.springframework.validation.BindException]; nested exception is java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature!
  2. 0

    Instead of using a command/form object, I bind much of my data to the request body. I expected that I could specify an Errors/BindingResult object after a @RequestBody method parameter. Currently, I do the following: {code} @RequestMapping(value = "/events", method = RequestMethod.POST) public String create(@RequestBody final Event event, final HttpServletResponse response, final Model model) throws BindException { final BindingResult result = new BeanPropertyBindingResult(event, ""); ValidationUtils.invokeValidator(this.eventValidator, event, result); if (result.hasErrors()) { throw new BindException(result); } ... } {code} I would like to do the following: {code} @RequestMapping(value = "/events", method = RequestMethod.POST) public String create(@RequestBody final Event event, final BindingResult result, final HttpServletResponse response, final Model model) throws BindException { ValidationUtils.invokeValidator(this.eventValidator, event, result); if (result.hasErrors()) { throw new BindException(result); } ... } {code} However, when I do, I receive the following exception: {code} 2010-04-21 09:48:09,014 [http-8080-2] WARN org.springframework.web.servlet.handler.SimpleMappingExceptionResolver - Handler execution resulted in exception org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public java.lang.String com.playonsports.event.controller.EventController.create(com.playonsports.event.bean.Event,org.springframework.validation.BindingResult,javax.servlet.http.HttpServletResponse,org.springframework.ui.Model) throws org.springframework.validation.BindException]; nested exception is java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature! at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716) ... Caused by: java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature! at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:264) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:163) ... 54 more {code}

    Spring JIRA | 7 years ago | Nick Padgett
    org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public java.lang.String com.playonsports.event.controller.EventController.create(com.playonsports.event.bean.Event,org.springframework.validation.BindingResult,javax.servlet.http.HttpServletResponse,org.springframework.ui.Model) throws org.springframework.validation.BindException]; nested exception is java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature!
  3. 0

    Controller: @Controller @RequestMapping("/*/menu/**") public class MenuTreeController { @RequestMapping("type/{code}") public ModelAndView getFirstLevelFunctionNodes(@PathVariable("code") String code) { } } I get following error for url like localhost:8080/book/menu/type/M5 org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public org.springframework.web.servlet.ModelAndView com.abc.MenuTreeController.getFirstLevelFunctionNodes(java.lang.String)]; nested exception is java.lang.IllegalStateException: Could not find @PathVariable [code] in @RequestMapping at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402) I works for me, before. Can you guys help me to solve this problem, thanks. btw, problem seems to be in AntPathStringMatcher.

    Spring JIRA | 7 years ago | Lei Zhang
    org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public org.springframework.web.servlet.ModelAndView com.abc.MenuTreeController.getFirstLevelFunctionNodes(java.lang.String)]; nested exception is java.lang.IllegalStateException: Could not find @PathVariable [code] in @RequestMapping
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    How to test that method has added redirectAttributes ?(by MockMvc)

    Stack Overflow | 3 years ago
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public java.lang.String com.epam.hhsystem.web.controllers.VacancyMenuController.myMethod(org.springframework.web.servlet.mvc.support.RedirectAttributes)]; nested exception is java.lang.IllegalStateException: Argument [RedirectAttributes] is of type Model or Map but is not assignable from the actual model. You may need to switch newer MVC infrastructure classes to use this argument.
  6. 0

    In test: Argument [RedirectAttributes] is of type Model or Map but is not assignable from the actual model. You may need to

    Stack Overflow | 3 years ago
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public java.lang.String com.epam.hhsystem.web.controllers.VacancyMenuController.updateVacancyPRG(org.springframework.ui.Model,org.springframework.web.servlet.mvc.support.RedirectAttributes,java.lang.Integer)]; nested exception is java.lang.IllegalStateException: Argument [RedirectAttributes] is of type Model or Map but is not assignable from the actual model. You may need to switch newer MVC infrastructure classes to use this argument.

    3 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.springframework.web.bind.annotation.support.HandlerMethodInvocationException

      Failed to invoke handler method [public java.lang.String com.playonsports.event.controller.EventController.create(com.playonsports.event.bean.Event,org.springframework.validation.BindingResult,javax.servlet.http.HttpServletResponse,org.springframework.ui.Model) throws org.springframework.validation.BindException]; nested exception is java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature!

      at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod()
    2. Spring
      HandlerMethodInvoker.invokeHandlerMethod
      1. org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171)
      1 frame
    3. Spring MVC
      DispatcherServlet.doService
      1. org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414)
      2. org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402)
      3. org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)
      4. org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
      4 frames