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 error
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 = Logger.getLogger(BufferedRequestWrapper.class.getName()); ByteArrayInputStream bais; ByteArrayOutputStream baos; BufferedServletInputStream bsis; byte[] buffer; HttpServletRequest request =null; public HttpServletRequest getHTTPRequest(){ return request; } public BufferedRequestWrapper(HttpServletRequest req) throws IOException { super(req); 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 = is.read(buf)) > 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 the // servlet engine!) bsis = new BufferedServletInputStream(bais); } catch (Exception ex) { ex.printStackTrace(); } 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. Validator.validate(bufferedRequest); fc.doFilter(bufferedRequest, res); } else { // for normal request //validate the input. Validator.validate(request); 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) 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) -- View this message in context: http://old.nabble.com/problem-while-reading-multipart-form-data-in-struts-tp26806463p26806463.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org