struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From binash <>
Subject problem while reading multipart/form-data in struts
Date Wed, 16 Dec 2009 05:27:56 GMT

We are using a validation framework to validate all input to our application.
This is implemented with a filter. In order to handle multipart form data
twice, we have created BufferedRequestWrapper class (as a sub class
'HttpServletRequestWrapper'). Now with this class I am able to get all the
form bean values in both filter class as well as in the struts ActionForms.
After saving the form data, i am redirecting the request to a jsp page which
includes global header page. In this included page i am getting following

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

In this page Struts try to populate(set methods) the form bean instead of
calling get methods. Here above exceptions is thrown in PropertiesUtil's
invoke method. please help to solve this problem. (we are not getting the
error if we pass Request objet instead of Wrapper object. in that case we
wont be able to get form data twice)

Wrapper class used is

public class BufferedRequestWrapper extends HttpServletRequestWrapper {

     * The variable holds the Log4j instance to log the INFO, DEBUG, ERROR
and FATAL events.
    private static Logger LOG =

    ByteArrayInputStream bais;
    ByteArrayOutputStream baos;
    BufferedServletInputStream bsis;
    byte[] buffer;
    HttpServletRequest request =null;
    public HttpServletRequest getHTTPRequest(){
        return request;

    public BufferedRequestWrapper(HttpServletRequest req) throws IOException
        this.request = req;
        // Read InputStream and store its content in a buffer.
        InputStream is = req.getInputStream();
        baos = new ByteArrayOutputStream();
        byte buf[] = new byte[1024];
        int letti;
        while ((letti = > 0)
            baos.write(buf, 0, letti);
        buffer = baos.toByteArray();

    public ServletInputStream getInputStream() {
        try {
            // Generate a new InputStream by stored buffer
            bais = new ByteArrayInputStream(buffer);
            // Istantiate a subclass of ServletInputStream
            // (Only ServletInputStream or subclasses of it are accepted by
            // servlet engine!)
            bsis = new BufferedServletInputStream(bais);
        } catch (Exception ex) {
        } finally {
            return bsis;


following code is  there in filter

if(request.getHeader(CONTENT_TYPE)!=null && isMultiPart() // checks if req
is multipart
                 bufferedRequest = new BufferedRequestWrapper(request);
                 //validate the input.
                 fc.doFilter(bufferedRequest, res);
              } else { // for normal request
                 //validate the input.
                 fc.doFilter(req, res);

exception thrown in jSP page is (this jsp page is part of view page after
the execution action class which handles form data)

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)
View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message