File Upload (struts) IllegalArgumentException

L

lb

Hi

I have this code in my jsp page:

<html:form action="FileUpload.do">
<html:file property="uploadFilename" />
<html:submit />
</html:form>

....and it works. The code in my action class gets executed.
But if I add the encode type property like this:

<html:form action="FileUpload.do" enctype="multipart/form-data">
<html:file property="uploadFilename" />
<html:submit />
</html:form>

....then the code in my action class is not executed. Instead I get this
error:

500 Internal Server Error
java.lang.IllegalArgumentException: 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:324)
at
org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.j
ava:1789)
at
org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.j
ava:1684)
at
org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:17
13)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
at
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.j
ava:821)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind[Oracle Application Server Containers for J2EE 10g
(9.0.4.0.0)].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.ja
va:65)
at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:356)
at com.evermind[Oracle Application Server Containers for J2EE 10g
(9.0.4.0.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispa
tcher.java:614)
at com.evermind[Oracle Application Server Containers for J2EE 10g
(9.0.4.0.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletReq
uestDispatcher.java:317)
at com.evermind[Oracle Application Server Containers for J2EE 10g
(9.0.4.0.0)].server.http.HttpRequestHandler.processRequest(HttpRequestHandle
r.java:784)
at com.evermind[Oracle Application Server Containers for J2EE 10g
(9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
at com.evermind[Oracle Application Server Containers for J2EE 10g
(9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
at com.evermind[Oracle Application Server Containers for J2EE 10g
(9.0.4.0.0)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableRe
sourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:536)


What am I missing?

Thanks in advance
Lars B.
 
L

lb

In case anyone is interested, I found the solution. The problem could easily
have been identified if the error message actually said something useful.



The problem is that "uploadFilename" in " <html:file
property="uploadFilename" />" is not a string . it's a FormFile.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top