Getting below Error in Struts application property is of Type String Array[] ...

private String procBatchCode[] = new String[25];
    public void setProcBatchCode(String[] strings) {
        procBatchCode = strings;
    }

package com.americanexpress.ms3.actionform.rejectedpayables;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.collections.MultiMap;


public class Test {



  public static void main(String args[]){
    RejectedPayablesCommonFormTest rj=new RejectedPayablesCommonFormTest();
  System.out.println("Calling .....");
    Map <String,Object>map=new HashMap<String,Object>() ;
    map.put("abc","abc");
    map.put("fromDate","FormDate");
   String[] batchCodeList={"015"};
    String []batchCode={"015"};
   map.put("procBatchCode",batchCode);
    map.put("procBatchCodeList",batchCodeList);


    try {
        org.apache.commons.beanutils.BeanUtils.populate(rj, map);

    }catch(Exception e){
      e.printStackTrace();
      }

    System.out.println("Calling ..End ..."+rj.getProcBatchCodeList().size()+" batch code list"+rj.getProcBatchCodeList().size());
      }



  }

...

java.lang.IllegalArgumentException: Cannot invoke com.americanexpress.ms3.actionform.rejectedpayables.RejectedPayablesCommonFormTest.setProcBatchCode - argument type mismatch at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:1778) at org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:1759) at org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1648) at org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:1677) at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1022) at org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811) at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298) at com.americanexpress.ms3.actionform.rejectedpayables.Test.main(Test.java:28)

1

There are 1 best solutions below

0
Rinat On

The type of the "procBatchCode" field in rj object does not match with the type of the object by key "procBatchCode" in the map.