top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Facing ambiguous map found exception while loading Spring web app

+2 votes
2,823 views

java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'roleTaskListController' bean method
public com.hp.dsm.usermgmt.model.Role com.hp.dsm.usermgmt.web.RoleTaskListController.listTask(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception
to {[/usermgmt/listTask],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'roleTaskListController' bean method
protected java.util.Map com.hp.dsm.usermgmt.web.RoleTaskListController.referenceData(javax.servlet.http.HttpServletRequest) throws java.lang.Exception mapped.


  • The above is the log snippet.
  • I do not have any duplicate mappings and the spring version I am using is Spring 3.2.1
posted May 2, 2013 by Pavithra Shenoy

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
Is it possible to put code sinppet here. U can edit the question and put more detail i.e. code.
@Controller
@RequestMapping("usermgmt/listTask")
public class RoleTaskListController extends BaseFormController {

    private static final long serialVersionUID = 8638654067225936024L;
    @Autowired
    private RoleManager roleManager;

    public void setRoleManager(RoleManager roleManager) {
        this.roleManager = roleManager;
    }

    @Autowired
    private GroupManager groupManager;

    public void setGroupManager(GroupManager groupManager) {
        this.groupManager = groupManager;
    }

    public RoleTaskListController() {

    }

    @RequestMapping(method = RequestMethod.GET)
    @ModelAttribute
    public Role listTask(HttpServletRequest request,
            HttpServletResponse response) throws Exception {
    // list task
    }
       

    @ModelAttribute
    protected Role showForm(HttpServletRequest request,
            HttpServletResponse response) throws Exception {
            // show form
    }

    @SuppressWarnings("rawtypes")
    @RequestMapping(method = RequestMethod.GET)
    protected Map referenceData(HttpServletRequest request) throws Exception {
        // return map
    }

}
In your code you have two requestMethod.Get (i.e. listTask and referenceData) which is root cause of the issue.
Check if you can add something like @RequestMapping(value = "myEdit", method = RequestMethod.GET) in one function and  @RequestMapping(value = "myCopy", method = RequestMethod.GET)  in other.

1 Answer

0 votes

Just making a guess of the common problem check if it helps:

If you have a controller as given below, all requests other than /book/edit will be directed to mydefault() while /book/edit will be sent to meet().

@Controller
@RequestMapping("/book")
public class BookController {

    @RequestMapping
    public @ResponseBody String mydefault() {
        return "Hi Book!";
    }

    @RequestMapping("/edit")
    public @ResponseBody String meet() {
        return "Nice to meet you Book!";
    }
}

It is a common problem where you have two methods without explicit path mapping.

answer May 3, 2013 by Salil Agrawal
...