Announcement Announcement Module
Collapse
No announcement yet.
get "Ambiguous handler methods mapped for HTTP path" exception after upgrading Roo Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • get "Ambiguous handler methods mapped for HTTP path" exception after upgrading Roo

    Hi,

    I have recently upgraded my project from 1.0.2.RELEASE to 1.1.4.RELEASE.

    I have a controller called PersonController in the project. But when I tried to update some fields of the person through the GUI it threw an error saying:

    Code:
    Ambiguous handler methods mapped for HTTP path (/Person/236)
    (My Class path)
    ...
    If you intend to handle the same path in multiple methods, then factor them out into a dedicated handler class with that path mapped at the type level!
    In the create method in PersonController, the mapping is:
    Code:
    @RequestMapping(value = "/person", method = RequestMethod.POST)
    It returns a string:
    Code:
    return "redirect:/person/" + person.getId();
    In the udpate method in PersonController, the mapping is:
    Code:
    @RequestMapping(method = RequestMethod.PUT)
    It returns a string:
    Code:
    return "redirect:/person" + person.getId();


    It seems my project is using the path in the create method after I updating something. I notice that in 1.1.4.RELEASE there is some new tags added to the create.jspx and update.jspx for the Controller, mapping create and update method respectively.
    They are form:create and form:update. They use different ids, but their paths are the same: path="/person".
    I have also deleted the "automaticallyMaintainView=true" in requestMapping because it is not supported in Roo 1.1.4.RELEASE.

    What could be causing this exception? How can I change the code to get rid of the exception?
    Last edited by newguy; May 29th, 2011, 11:08 PM.

  • #2
    Without knowing much of how 1.0.2 did it, it appears that your PersonController create() uses the /person requestmapping, but your update() does not. I'm assuming you have other controllers, so how does it know to send the update() to this particular controller.

    Although not required, you will commonly see a requestmapping all the class level for a restful controller eg.

    Code:
    @RequestMapping("/servicemessages")
    @Controller
    public class ServiceMessageController
    followed by
    Code:
    @RequestMapping(method = RequestMethod.POST)
        public String create(@Valid ServiceMessage serviceMessage, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
    
     @RequestMapping(method = RequestMethod.PUT)
        public String update(@Valid ServiceMessage serviceMessage, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
    This makes it easier to avoid ambigious resolution.

    You can also turn debug logging on, I think on the dispatcherServlet from memory, and it tells you when the system is starting up what patterns its going to map. Good to sanity check that.

    Comment


    • #3
      Thanks for your reply. The project worked fine before I upgraded so I suppose Roo figured out how to send the update().

      I have also removed automaticallyMaintainView = true in @RooWebScaffold during upgrade so I am not sure if this is what causing the problem.

      Comment

      Working...
      X