Results 1 to 3 of 3

Thread: org.springframework.web.util.NestedServletExceptio n: Request processing failed

  1. #1
    Join Date
    Jan 2013
    Posts
    2

    Default org.springframework.web.util.NestedServletExceptio n: Request processing failed

    Hi all,
    I am doing CRUD using spring jdbc template.
    insert,select and delete operations are working fine but I got these following exception in update process.

    Code:
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [java.lang.Integer]: No default constructor found; nested exception is java.lang.NoSuchMethodException: java.lang.Integer.<init>()
    here is my controller:

    Code:
    @RequestMapping(value="/editCompany/{companyId}", method= RequestMethod.GET)
        public String edit(@PathVariable(value="companyId")Integer companyId,ModelMap map) {
    		
    		Company company=companyService.get(companyId);
    		map.addAttribute("company", company);
    		map.put("companyId", companyId);
    		return "editCompany"; 
        }
    	
    	@RequestMapping(value="/editCompany/{companyId}", method= RequestMethod.POST)
            public String save(@ModelAttribute("company")Integer companyId,Company company,BindingResult result, ModelMap map) {
    		
    		companyValidator.validate(company, result);
    		if (result.hasErrors()) {
    			return "editCompany";
    		} else {
    			Integer i=companyService.save(company);
    			
    			return "status";
    		}
        }
    I have used @Autowired annotation for the controller too.
    How to resolve it? any kind of help is appreciated.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    You shouldn't use copy/paste to construct your methods... YOur Post method is wrong...

    Code:
    public String save(@ModelAttribute("company")Integer companyId,Company company,BindingResult result, ModelMap map)
    Remove the highlighted part... Companyid is a path variable not a model attribute, Company is the model attribute (at least if it is stored inbetween request or fully populated upon requests).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Jan 2013
    Posts
    2

    Default

    Quote Originally Posted by Marten Deinum View Post
    You shouldn't use copy/paste to construct your methods... YOur Post method is wrong...

    Code:
    public String save(@ModelAttribute("company")Integer companyId,Company company,BindingResult result, ModelMap map)
    Remove the highlighted part... Companyid is a path variable not a model attribute, Company is the model attribute (at least if it is stored inbetween request or fully populated upon requests).
    thanks for correcting me.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •