Code flow is attached, forgot to attach in trailing mail.
________________________________ From: Rahul Singh <rksing...@hotmail.com> Sent: Monday, January 18, 2016 8:39 AM To: Tomcat Users List Subject: Re: File size >= 2GB not uploaded in application [Tomcat 7.0.54 Struts: 2.3.24 JAVA: openJDK 1.7.79] Hello Christopher, thanks for your prompt response !! > Why didn't you come to the Tomcat community first? Sorry for the delay, we wanted to make sure about the component causing the problem. >>I don't have a test-case in front of me, but I'm fairly confident that >>Tomcat allows file uploads of greater than 2GiB. I suspect the problem is another component. >>Are you using Servlet 3.0-based file upload, or are you allowing >>Struts to handle the file-upload for you? If you use Servlet-3.0 >>file-upload, then you'll have code that deals with Multipart classes >>and configuration in web.xml. If you are using Struts's file-upload, >>then you'll mostly just be calling getFile or getInputStream or >>however Struts 2 does things (I can't remember how it all works off >>the top of my head). In our case the filter class implements the javax.servlet.flter and imports javax.servlet.* The Filter class mentioned in the previous threads is the first one as declared in the web.xml (followed by other struts filters). All (url) requests are mapped to this filter. So this is where our file upload request goes. It is only in greater than 2 gb file upload request that the dofilter() fails to get any request. So we feel servlet 3.0 being used in our case the Filter is not being able to handle greater than 2 gb requests. >>The point is, if you are using Struts, then Tomcat will not touch the >>request and Struts is handling the whole thing. If Struts is the >>problem, you'll need to talk to the Struts team[1]. >>If you are using Servlet-3.0 file-upload, then Struts is just a red >>herring and this is the right place to get your issue solved. As mentioned above Servlet 3.0 is being used. So request the tomcat community to please look into our issue. >>So far, you have posted some configuration for Struts and some JSP >>tablib-filled code, plus some Java code for a Filter. You didn't say >>where the Filter was in the filter chain (before or after Struts >>filter). You also mentioned that the form is actually posted using >>XMLHttpRequest and not through a standard form, but you didn't explain >>what component is doing that or how it actually works. >>There isn't enough information here to make any sense of the >>situation. Can you please address all of the questions I've posed >>above and maybe we can then help you? <<<Code model >>>> We need to model the following code to be told: jsp submit of the form How the .js submit it further in XmlHttpRequest How the Filter is declared How the web.xml is declared >Are you sure the request is even made to the server in these cases?What if the >Javascript upload component is failing before it even starts? Yes the request is made in these cases. We have compared the scenario for greater than 2gb and lesser size file uploads and drawn the following inference from it.We have checked the request and content length for dofilter() method in our logs. The JavaScript is not the culprit in this case. The JavaScript sets the AJAX field to success after sending request and thereafter waits for response(which is not received in our case). Our application works fine for lesser than 2 gb fie uploads but fails for greater size files as the request fails to reach the dofilter() method after which the request can be forwarded to the requested method. Regards, Rahul ________________________________________ From: Christopher Schultz <ch...@christopherschultz.net> Sent: Saturday, January 16, 2016 9:33 AM To: Tomcat Users List Subject: Re: File size >= 2GB not uploaded in application [Tomcat 7.0.54 Struts: 2.3.24 JAVA: openJDK 1.7.79] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Rahul, On 1/15/16 1:02 AM, Rahul Singh wrote: > Thanks for your guidelines, we have big hope from Apache Tomcat > Team to solve this problem as this is show stopper for our > application, we have also raise this question on various forum like > stack overflow and other, but no relevant reply till now. Why didn't you come to the Tomcat community first? > Hope you understand my situation, > > please refer the below stackoverflow reference for more detail > about this issue. > > http://stackoverflow.com/questions/34783438/dofilter-fails-to-get-any- [http://cdn.sstatic.net/stackoverflow/img/apple-touch-i...@2.png?v=73d79a89bded&a]<http://stackoverflow.com/questions/34783438/dofilter-fails-to-get-any-> doFilter() fails to get any request for the file upload > 2gb<http://stackoverflow.com/questions/34783438/dofilter-fails-to-get-any-> stackoverflow.com For my struts project the doFilter() fails to get any request from the file upload form in cases the size of the file is greater than 2gb. Below is the code fragment: Filter (class is FilterUp) is... request-for-the-file-upload-2gb?noredirect=1#comment57315528_34783438 > > > for more information: > > -No error are printed in tomcat logs. - how to configure "call > HttpServletRequest.getHeader("Content-Length") as a String and > parse it yourself." I don't have a test-case in front of my, but I'm fairly confident that Tomcat allows file uploads of greater than 2GiB. I suspect the problem is another component. Are you using Servlet 3.0-based file upload, or are you allowing Struts to handle the file-upload for you? If you use Servlet-3.0 file-upload, then you'll have code that deals with Multipart classes and configuration in web.xml. If you are using Struts's file-upload, then you'll mostly just be calling getFile or getInputStream or however Struts 2 does things (I can't remember how it all works off the top of my head). The point is, if you are using Struts, then Tomcat will not touch the request and Struts is handling the whole thing. If Struts is the problem, you'll need to talk to the Struts team[1]. If you are using Servlet-3.0 file-upload, then Struts is just a red herring and this is the right place to get your issue solved. So far, you have posted some configuration for Struts and some JSP tablib-filled code, plus some Java code for a Filter. You didn't say where the Filter was in the filter chain (before or after Struts filter). You also mentioned that the form is actually posted using XMLHttpRequest and not through a standard form, but you didn't explain what component is doing that or how it actually works. There isn't enough information here to make any sense of the situation. Can you please address all of the questions I've posed above and maybe we can then help you? Are you sure the request is even made to the server in these cases? What if the Javascript upload component is failing before it even starts ? - -chris [1] http://struts.apache.org/mail.html > ________________________________________ From: Christopher Schultz > <ch...@christopherschultz.net> Sent: Thursday, January 14, 2016 > 8:43 PM To: Tomcat Users List Subject: Re: File size >= 2GB not > uploaded in application [Tomcat 7.0.54 Struts: 2.3.24 JAVA: openJDK > 1.7.79] > > André, > > On 1/14/16 5:02 AM, André Warnier (tomcat) wrote: >> I have not followed this thread in details, but did you check >> this : >> >> http://tomcat.apache.org/tomcat-7.0-doc/config/http.html#Common_Attri butes >> >> >> - --> maxPostSize > > +1 > >> The maximum size in bytes of the POST which will be handled by >> the container FORM URL parameter parsing. The limit can be >> disabled by setting this attribute to a value less than zero. If >> not specified, this attribute is set to 2097152 (2 megabytes). >> Note that the FailedRequestFilter can be used to reject requests >> that exceed this limit. >> >> Note: the size above might relate to the *encoded* size of the >> file, as it is transmitted over the WWW (possibly encoded as >> Base64 e.g.), which may mean that an original 1 MB file >> translates to more than 1 MB bytes while being uploaded. >> >> Note also : maybe "Struts" is setting this to some other default >> value.. >> >> Another question : did you check the Tomcat logs ? > > IIRC, Tomcat doesn't log anything in these cases. You have to use > the FailedRequestFilter to detect and report the condition. I > wouldn't use that Filter in productio, but it would be good as a > simple test to see if this is the error that is occurring. > > When Tomcat refuses to allow a file upload that it too large, it > simply does not parse the parameters, but the request continues to > process as usual (but the servlet doesn't end up getting any of > the parameters). I'm surprised that Struts isn't getting the > request in these cases. > > -chris > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlaZwQoACgkQ9CaO5/Lv0PDK1QCgp3jd6JQEq8uqDyliApixCmU+ C/cAn01SXu7E1CXvuwt7W09TQb5lvHUk =xySZ -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
<JSP> <s:form id="uploadData" action="UploadAction" namespace="xyz" validateFields="false" method="post" enctype="multipart/form-data"> ================================================================================================================================ <JAVA Script> $forms.submit( function() { if (!validator(this)) { return false; } var $form = $(this); var confirmOnOK = $form.data(consts.DATA_CONFIRM_CALLBACK); var confirmOnCancel = $form.data(consts.DATA_CONFIRM_CANCEL); var confirmMsg = $form.data(consts.DATA_CONFIRM_MSG) || $form.attr(consts.ATTR_CONFIRM_MSG); if (confirmMsg) { var onOK = $.proxy( function() { if (!$.isFunction(confirmOnOK)) { confirmOnOK = function() { }; } if (confirmOnOK.apply(this, arguments) !== false) { formSubmit(this); } }, this); projectName.confirm(confirmMsg, onOK, confirmOnCancel); } else { formSubmit(this); } $form.removeData(consts.DATA_CONFIRM_MSG); $form.removeData(consts.DATA_CONFIRM_CALLBACK); $form.removeData(consts.DATA_CONFIRM_CANCEL); return false; } formSubmit : function(form) { var $form = $(form); var $spinner = $form.data(consts.DATA_FORM_SPINNER); $form.ajaxSubmit( { timeout : 0, beforeSerialize : function(formObj, options) { if ($(':file', formObj).length <= 0) { return; } options.iframe = true; if (!options.data) { options.data = {}; } options.data['fileUploadMode'] = true; }, beforeSubmit : function(json, $form, options) { $(consts.SELECTOR_TO_VALIDATE, $form).each( function() { utils.abortFieldRequest(this); return true; }); $form.data(consts.FLAG_SUBMITTED, true); if ($spinner) { project.spinner.show($spinner); } }, success : function(json, status) { exception.hideDialog(); var result = utils.parseAjaxData(json); var ret, returnHandler = utils.eventHandler(form, consts.EVENT_RETURN); if ($.isFunction(returnHandler)) { ret = returnHandler.apply(form, result); } utils.processReturn(ret, result, form); }, complete : function() { $form.data(consts.FLAG_SUBMITTED, false); if ($spinner) { project.spinner.hide($spinner); } }, error : function(response, status, e) { var message = ""; try { message = response.responseText; }catch(e){} if (message) { exception.showDialog(form).html(message); } } }); }, abortFieldRequest : function(element) { var consts = project.constants; var request = $(element).data(consts.AJAX_REQUEST); if (request) { request.abort(); $(element).removeData(consts.AJAX_REQUEST); } }, constants : { AJAX_REQUEST : "XMLHttpRequest", } ======================================================================================== Web.xml (following is only used filter for all request) <filter> <filter-name>FilterUp</filter-name> <filter-class>abc.xyz.FilterUp</filter-class> <init-param> <param-name>autoTimeout</param-name> <param-value>1800</param-value> </init-param> </filter> <filter-mapping> <filter-name>FilterUp</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> ======================================================================================= JAVA Filter implementation public class FilterUp implements Filter { public void init(FilterConfig config) throws ServletException { } public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; ** check request ** } public void destroy() { } } ==========================================================================================
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org