• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem while reading multipart/form-data

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using some validation on the input data.I am handiling this validation through the fiklter class.
For the GET request, getting all the values from the 'form bean' using 'request.getParameterNames()'
method. But in 'multipart/form-data' the 'form bean' values are not geeting from the normal request.
Inorder to solve this problem I used the 'BufferedRequestWrapper' class which extends 'HttpServletRequestWrapper'
class. Through this class I am able to get all the form bean values in both filter class as well as in the ActionForm class.
But now I am getting error after doing all the database operations. ie, it is doing the validation and redirect to the action class and saving the data in DB.
but coming back to the browser, it is displaying errors. It is throwing the errors like this.

java.lang.IllegalArgumentException: Cannot invoke Form.setCompanyLogo - argument type mismatch.

The following code snippet Iam using in filter class to handle the 'multipart/form-data'

public void doFilter(ServletRequest req, ServletResponse res, FilterChain fc)throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
BufferedRequestWrapper bufferedRequest = new BufferedRequestWrapper(request);
fc.doFilter(bufferedRequest, res);
}


Please help me to solve this problem....

Thanks in advance..
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This seems like a struts problem to me, so I'll move it there...
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
add it line as <html:form action="/" enctype="multipart/form-data">
 
Ankit Garg
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

java.lang.IllegalArgumentException: Cannot invoke Form.setCompanyLogo - argument type mismatch.


Can you show us the code of the Form class. Also the code of the JSP which submits values to the action. Also which BufferedRequestWrapper class are you using??
 
nithya Xavier
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the issue happens when the input type multipart and when using request wrapper.

filter has following code



JSP code is



The above jsp has an image upload. On submit, this action is completed and stores info and image successfully. then redirect to page which include global page which has a tile def. the tile def has following struts config entry



form bean is




Now its throws MPForm.setCompanyLogo - argument type mismatch' . and someaction is never getting called


 
nithya Xavier
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Request wrapper has following code

 
nithya Xavier
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is error thrown

19:49:22,785 ERROR [PropertyUtils] Method invocation failed.
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:1773)
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)




This exception is thrown when struts trying to populate form beam MPForm. However, there is no need to populate form, as we are displaying a page with form bean MPForm. Why struts tries to populate form bean in this case? (This happens when we wrap request for multipart request)

 
nithya Xavier
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please help
 
nithya Xavier
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone help me please?

thanks
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic