Return-Path: Delivered-To: apmail-myfaces-users-archive@www.apache.org Received: (qmail 40502 invoked from network); 22 Sep 2010 20:42:56 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 22 Sep 2010 20:42:56 -0000 Received: (qmail 34217 invoked by uid 500); 22 Sep 2010 20:42:55 -0000 Delivered-To: apmail-myfaces-users-archive@myfaces.apache.org Received: (qmail 33517 invoked by uid 500); 22 Sep 2010 20:42:54 -0000 Mailing-List: contact users-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Discussion" Delivered-To: mailing list users@myfaces.apache.org Received: (qmail 33033 invoked by uid 99); 22 Sep 2010 20:42:54 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Sep 2010 20:42:54 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [78.46.64.122] (HELO zimbra.elbe-net.de) (78.46.64.122) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Sep 2010 20:42:29 +0000 Received: from localhost (localhost [127.0.0.1]) by zimbra.elbe-net.de (Postfix) with ESMTP id A04FAEC131 for ; Wed, 22 Sep 2010 22:42:35 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.elbe-net.de Received: from zimbra.elbe-net.de ([127.0.0.1]) by localhost (zimbra.elbe-net.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oW6s83VKx9tI for ; Wed, 22 Sep 2010 22:42:33 +0200 (CEST) Received: from [192.168.1.36] (f054152231.adsl.alicedsl.de [78.54.152.231]) by zimbra.elbe-net.de (Postfix) with ESMTPSA id 7629FEC10F for ; Wed, 22 Sep 2010 22:42:33 +0200 (CEST) Message-ID: <4C9A6A12.5020509@elbe-net.de> Date: Wed, 22 Sep 2010 22:41:54 +0200 From: Michael Kakuschky User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4 MIME-Version: 1.0 To: MyFaces Discussion Subject: Re: [Tobago] FileUpload from popup supported? References: <4C986534.50301@elbe-net.de> <4C989A29.4010207@schnurpfeil.de> In-Reply-To: <4C989A29.4010207@schnurpfeil.de> Content-Type: multipart/alternative; boundary="------------020509060700040401070209" X-Virus-Checked: Checked by ClamAV on apache.org --------------020509060700040401070209 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Hello Udo, thanks for the quick response. I go forward did some checks and tests: - application is running on Tomcat 6.0.18 with myfaces 1.2.8 and tobago 1.0.24 on a Windows7 x64 machine - I moved the file-upload form from the popout to a normal form. Same error so the popup is not responsible - I checked my web.xml file for the filter configuration. It's there. - I want to install the tobago-fileupload.jar but can't find it in the tobago myfaces-tobago-1.0.28-dist.zip. Where can I find it? - It's also not pretty clear for me where to place the elements described in at http://myfaces.apache.org/tobago/apidocs/org/apache/myfaces/tobago/fileupload/FileUploadFacesContextFactoryImpl.html The file upload process works basically. What I do is to open the filestream read the data to a buffer and then copy the buffer via a setter function of a class to another buffer OR I set the size via the setter, here I got the exception. Since I got the exception also setting the size element it depends not directly to the buffer-copy operation. Here is the snippset of the upload handling code. ticketAttachment an instance of class org.apache.commons.fileupload.FileItem: if (ticketAttachment.getSize() > 0 ) { InputStream inStream; OutputStream outStream; // read Data to memory buffer try { inStream = ticketAttachment.getInputStream(); } catch (IOException e) { e.printStackTrace(); return null; } int fSize = (int) ticketAttachment.getSize(); byte [] buffer = new byte[fSize*2]; try { int readbytes = 0; readbytes = inStream.read(buffer, 0, fSize); inStream.close(); } catch (IOException e) { e.printStackTrace(); return null; } try { // create new TicketAttachment object ticketAttachmentToAdd.setTicket(ticketToAdd); ticketAttachmentToAdd.setCreated(new Date()); ticketAttachmentToAdd.setFilename(ticketAttachment.getName()); ticketAttachmentToAdd.setSize(fSize); // HERE THE EXCEPTION IS FIRED ticketAttachmentToAdd.setData(buffer); // IF I OUCOMMNET THE PRVIOUS Line it happens here .... with the both lines setting size and data to my Attachment Hibernate model class there is no problem. The relevant part of the TicketAttachment class is: public class TicketAttachment { private Integer size; private byte[] data; public void setSize(Integer size) { this.size = size; } public void setData(byte[] data) { this.data = data; } The stacktrace looks like the following. See the read line there is an Exception about a missing setter function. But the missed function is not existing and calles from nowhere. Looks that there is some garbage inside "|*Ljava/lang/Integer;)V at" *|Looks like a buffer overflow which writes some garbage to the function call |javax.faces.FacesException: Error calling action method of component with id page:j_id_jsp_885078903_2:j_id_jsp_885078903_17 at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72) at javax.faces.component.UICommand.broadcast(UICommand.java:127) at org.apache.myfaces.tobago.component.UIViewRoot.broadcastForPhase(UIViewRoot.java:135) at org.apache.myfaces.tobago.component.UIViewRoot.processApplication(UIViewRoot.java:211) at org.apache.myfaces.tobago.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:30) at org.apache.myfaces.tobago.lifecycle.TobagoLifecycle.executePhase(TobagoLifecycle.java:101) at org.apache.myfaces.tobago.lifecycle.TobagoLifecycle.execute(TobagoLifecycle.java:75) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:178) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter.doFilter(TobagoMultipartFormdataFilter.java:127) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Unknown Source) Caused by: *javax.faces.el.EvaluationException: java.lang.NoSuchMethodError: com.mycompany.model.TicketAttachment.setSize(Ljava/lang/Integer;)V at *org.apache.myfaces.el.convert.MethodExpressionToMethodBinding.invoke(MethodExpressionToMethodBinding.java:79) at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:57) ... 23 more Caused by: java.lang.NoSuchMethodError: com.mycompany.model.TicketAttachment.setSize(Ljava/lang/Integer;)V at com.mycompany.billing.BillingController.newTicket(BillingController.java:2622) 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.el.parser.AstValue.invoke(AstValue.java:172) at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) at org.apache.myfaces.el.convert.MethodExpressionToMethodBinding.invoke(MethodExpressionToMethodBinding.java:75) ... 24 more | Am 21.09.2010 13:42, schrieb Udo Schnurpfeil: > Hello Michael, > > there are two options to use the fileupload, see > http://myfaces.apache.org/tobago/faq.html#tobagofileupload > The jar-option might be better than the filter-option. > You can find an example in the addressbook demo. > > If you still have problems with the Java exceptions, please sent it, > with the Tobago version and the way you chose (jar or filter). > > Regards, > > Udo > > An example you can find in the > > Am 21.09.10 09:56, schrieb Michael Kakuschky: >> Hello, I use a form in a popup to submit some data. It worked fine >> until I add the tx:file component to the form. >> If I submit the form with a file selected I receive the data but it >> seems that it corrupts somehow the memory and I got some strange Java >> exceptions about (existing) methods that can't be found. >> >> If the file upload is supported can somebody give me a basic example >> and maybe tell me which attributes have to be set and which maybe not? >> >> KInd regards Michael >> --------------020509060700040401070209--