1

Adding the following the to struts.xml in struts2.3.24:

<constant name="struts.multipart.parser"  value="jakarta-stream" />
<constant name="struts.multipart.maxSize" value="3147483648" />

For reference the upload works as follows in the jsp:

<s:form id="uploadData" action="abc_UploadAction?method=Upload" namespace="xyz"   validateFields="false" method="post"    enctype="multipart/form-data">

For action mapping we use the concept of DMI. The action configuration is as follows:

<action name="abc_*" class="ABCAction">
<result type="chain">invoke_${module}_{1}_${method}</result>
</action>

But file upload still not working for large files of greater than 2gb. But the above code works fine for lesser size uploads,

1 Answers1

0

Why are you declaring a bean, if the documentation is not telling you to do so ?

Just change

<bean type="org.apache.struts2.dispatcher.multipart.MultiPartRequest" name="jakartaStream"
     class="org.apache.struts2.dispatcher.multipart.JakartaStreamMultiPartRequest" 
     scope="default" />
<constant name="struts.multipart.parser"  value="jakartaStream" />

to the right configuration that should be (hyphenized, not capitalized):

<constant name="struts.multipart.parser"  value="jakarta-stream" />
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
  • Thanks for your answer. I have made the above changes but even then the file uploads more than 2 gb are not successful. – p_saurabh92 Jan 11 '16 at 09:28
  • please post the list of the jars you're using – Andrea Ligios Jan 11 '16 at 09:35
  • P.S: I've seen now your code is from the JIRA, btw it's not needed anymore to declare the bean, since it's been put in the struts core from 2.3.18 – Andrea Ligios Jan 11 '16 at 09:37
  • List of jars: struts2-core-2.3.24 struts2-dojo-plugin-2.3.24 struts2-json-plugin-2.3.24 xwork-core-2.3.24 commons-io-2.2 freemarker-2.3.22 asm-tree-3.3 asm-commons-3.3 asm-3.3 log4j-1.2.17 ognl-3.0.6 javassist-3.11.0.GA commons-lang3-3.2 commons-fileupload-1.3.1 commons-logging-1.1.3. Yes have removed the bean on your advice and it works fine for less than 2 gb uploads but still not working for greater than 2gb uploads – p_saurabh92 Jan 11 '16 at 09:54
  • They're fine. Are you extending struts-default in your package ? Do you see any error in server / app logs ? Also show your action configuration – Andrea Ligios Jan 11 '16 at 10:00
  • Yes we extend struts-default,json-default in our package. No error in server or app logs is obtained. Just that the uploading gives no response for greater than 2 gb file uploads. For action configuration details I have updated the code details in the question. Please refer. – p_saurabh92 Jan 11 '16 at 10:25
  • Can you show the content of the action that is uploading the file ? Also, try not using chain that is discouraged :/ – Andrea Ligios Jan 11 '16 at 10:31
  • It is just that the form action refers to method Upload of the class UploadAction.java . In this method we have the business logic for file upload. – p_saurabh92 Jan 11 '16 at 10:35
  • I know, I've asked you the action definition to check if there were problems with the interceptor stack configuration, and now I'm asking you the action code to check if there are problems with the variables involved in the upload... the file and the two strings with filename and contenttype. Everything seems fine until now, I'm just shooting in the dark if can't see the code – Andrea Ligios Jan 11 '16 at 10:42
  • @ Andrea,the code does not reach upto there. It is only in the POST phase after which the content type and filename are to be determined. But I have made all necessary configuration for Tomcat. The request is not forwarded from there itself. Any idea on probable reason?? – p_saurabh92 Jan 11 '16 at 13:48
  • Between the JSP post and the action method there is a stack of interceptors. If the action is not reached, then the flow has been interrupted in some interceptor. You need to put devMode constant to true, and report here the exception, error message, warning message or whatever is printed in the logs that explain what is happening and where – Andrea Ligios Jan 11 '16 at 14:01