java.lang.IllegalArgumentException: Cannot invoke UploadForm.setUplaod - argument type mismatch
Degree DegreeS
Greenhorn
Joined: Jan 16, 2010
Posts: 2
posted
0
Hi
i want to uplaod Excel sheet data into database with POI features in struts 1.2 but it giving the error.
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 org.apache.struts.util.RequestUtils.populate(RequestUtils.java:467)
at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:818)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:194)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
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:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
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:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
stringAppend = new StringBuilder();
StringBuilder stringAppend1 = new StringBuilder();
stringAppend1.append("\n***********************************************************************\n\n");
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
currenttime = dateFormat.format(date);
stringAppend1 = stringAppend1.append(currenttime + " Skipped Lines are : " + "\n\n");
logger.debug("------Before getting the connection from database-----");
logger.debug("------After getting the connection from database----");
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(fileToCreate));
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow row;
int rows; // No of rows
rows = sheet.getPhysicalNumberOfRows();
int cols = 0; // No of columns
int tmp = 0;
// This trick ensures that we get the data properly even if it doesn't start from first few rows
for (int i = 0; i < 10 || i < rows; i++) {
row = sheet.getRow(i);
if (row != null) {
if (totalCnt != successCnt) {
fileTowrite = new File(filepath, "uploadfile.log");
FileWriter logfile = new FileWriter(fileTowrite, true);
Writer wr = new BufferedWriter(logfile);
wr.write(stringAppend1 + "\n");
wr.close();
}
if (totalCnt == successCnt) {
am.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage("Uploaded Successfully"));
//addActionMessage("Uploaded Successfully");
} else if (errorCnt == totalCnt) {
errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage("Unable to upload the file because of invalid data.<br/>View the <a target='_new' href='../file?fileName=uploadfile'>log file</a> for more details."));
} else {
errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage("Some of the records in the file are not uploaded because of invalid data. <br/>View the <a target='_new' href='../file?fileName=uploadfile'>log file</a> for more details."));
}
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.
Note, however, that this code doesn't actually help: the error occurs before your action is being executed (see the stack trace you posted previously).
I'd also urge you to refactor your action method: it's too long and is responsible for too many things.