title: argument type mismatch in spring
body: <p>I am getting </p>
  
  <pre><code>java.lang.IllegalArgumentException: argument type mismatch
  </code></pre>
  
  <p>when i am submitting my jsp to controller. Please suggest me why i am getting this error?</p>
  
  <p>Here is the StackTrace</p>
  
  <pre><code>java.lang.IllegalArgumentException: argument type mismatch
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
  at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
  at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
  at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
  at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
  at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
  at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at com.as.brc.filters.LoggingFilter.doFilter(LoggingFilter.java:66)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
  at java.lang.Thread.run(Thread.java:619)
  </code></pre>
  
  <p>I used commandName in jsp</p>
  
  <p>This is what I used in controller  </p>
  
  <pre><code>@RequestMapping("/save.do")
      public ModelAndView save(ModelAndView model,@ModelAttribute("classCommand")PurchaseMrn mrn,HttpServletRequest request,HttpServletResponse response,HttpSession session) throws JRException{
          User user=(User)session.getAttribute("loginuser");
          Business business=(Business)session.getAttribute("business");
          System.out.println("Business Is:"+business.getBusinessId());
          mrn.setCreatedBy(user.getId());
          mrn.setCreatedDate(new java.util.Date());
          mrn.setBusinessId(business);
          List&lt;Stock&gt; stockList=new ArrayList&lt;Stock&gt;();
          Stock stock=null;
          int i=0;
          String sid=new String();
          List&lt;Integer&gt; idList=new ArrayList&lt;Integer&gt;();
          List&lt;PurchaseMrnItem&gt; mrnItemsList=new ArrayList&lt;PurchaseMrnItem&gt;();
  
          List&lt;PurchaseOrder&gt; purchaseList=new ArrayList&lt;PurchaseOrder&gt;();
          int id=0;
          int sno=1;
          long total=0;
          Item item=null;
          for(PurchaseMrnItem mrnItem:mrn.getPurchaseMrnItems()){
              if(request.getParameter("itemId"+i)!=null){
                  int itemId=Integer.parseInt(request.getParameter("itemId"+i));
                  item=itemsService.findById(itemId, business.getBusinessId());
                  mrnItem.setBusinessId(business);
                  mrnItemsList.add(mrnItem);
                  stock=new Stock(business,mrnItem.getItem(),mrnItem.getRecievedQty(),mrnItem.getAmount());
                  stockList.add(stock);
                  sid=request.getParameter("id"+i);
                  id=Integer.parseInt(sid);
                  idList.add(id);
                  PurchaseOrder po=new PurchaseOrder(sno,item.getItemName(),item.getUnitType(),mrnItem.getRecievedQty(),mrnItem.getUnitPrice(),mrnItem.getSubtotal());
                  purchaseList.add(po);
                  total+=mrnItem.getSubtotal();
                  sno++;
              }
              i++;
          }
          mrn.setPurchaseMrnItems(mrnItemsList);
          poService.addPOMRN(mrn);
          poService.saveStock(stockList);
          poService.updatePR(idList);
          String prNumber=request.getParameter("prNumber");
          String prDate=request.getParameter("prDate");
          String poDate=request.getParameter("poDate");
          String dcDate=request.getParameter("dcInvoiceDate");
  
          Map&lt;String, Object&gt; parameters = new HashMap&lt;String, Object&gt;();
          parameters.put("total",total+"");
            parameters.put("poNumber",mrn.getPoNumber()+"");
            parameters.put("dcNumber",mrn.getDcInvoiceNo()+"");
            parameters.put("vehicleNo",mrn.getVehicleNo()+"");
            parameters.put("prNumber",prNumber);
            parameters.put("prDate",prDate);
            parameters.put("poDate",poDate);
            parameters.put("dcDate",dcDate);
  
  
            JasperReport report = (JasperReport) JRLoader.loadObject(session
                      .getServletContext().getResourceAsStream(
                              "/WEB-INF/reports/mrn.jasper"));
              JasperPrint prt = JasperFillManager.fillReport(report, parameters,
                      new JRBeanArrayDataSource(purchaseList.toArray()));
              byte[] pdfReport = JasperExportManager.exportReportToPdf(prt);
              //System.out.println("PDF Length Is: "+pdfReport.length);
  
              Long count=poService.getMRNCount(business.getBusinessId(),Constants.ST_CPMRN);
              String invoiceNumber=business.getShortname()+"/"+Constants.ST_CPMRN+"/"+count;
  
              Attachment attachment=new Attachment(business,"application/pdf",invoiceNumber,pdfReport,Constants.ST_CPMRN);
            attachemntService.insert(attachment);
  
  
          //stockList=null;
          //stock=null;
          model=new ModelAndView("/jsp/stock/ShowPdf.jsp","msg", "Purchases  Added Successfully with MRN Number "+invoiceNumber);
          model.addObject("number",invoiceNumber);
          model.addObject("attachType",Constants.ST_CPMRN);
          return model;
      }
  </code></pre>