Hi everybody.
I'm trying to use a form to upload several files, all at once.
I use
Struts and Commons facilities (that is the FormFile interface).
Here's my action form:
public class AttachmentForm
extends ActionForm {
/* Files to upload */
private FormFile[] uploadedFiles;
public FormFile[] getUploadedFiles() {
return uploadedFiles;
}
public void setUploadedFiles(FormFile[] uploadedFiles) {
this.uploadedFiles = uploadedFiles;
}
}
And this is the html code I use to populate the action form (I'm using Velocity, but I don't think this is really important):
<html>
<body>
...
<form name="uploadForm" method="post" enctype="multipart/form-data" action="(...my action...)">
...
Attachment 1: <input type="file" name="uploadedFiles"/>
Attachment 2: <input type="file" name="uploadedFiles"/>
Attachment 3: <input type="file" name="uploadedFiles"/>
...
</form>
...
</body>
</html>
Everytime I submit the form I obtain this exception:
javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
java.lang.IllegalArgumentException: argument type mismatch
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1789)
org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1684)
org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1713)
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
If I adjust the
java source to manage one file only (ie. FileForm instead of FileForm[]) it works, but as I try to use an array I get the Exception.
I use struts 1.1 on Windows XP platform and
Tomcat 5.0.24.
Have you got any ideas? Is it a bug of commons-beanutils?
Thanks in advance,
Paul