Search code examples
file-uploadstruts2apache-commons-fileupload

Struts2 file upload - No mapping found for dependency


I'm using Struts 2.3.20.1 with Commons File Upload 1.3.1 and Commons IO 2.4 to upload a (CSV) file. When i try to do uploading, there is this error in server log:

ERROR [io.undertow.request] (default task-24) UT005023: Exception handling request to /private/createDatasetFromCSV: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=java.lang.String, name='struts.multipart.bufferSize'] in public void org.apache.struts2.dispatcher.multipart.JakartaStreamMultiPartRequest.setBufferSize(java.lang.String).

I've followed the official guidelines here, creating an Action class, using the JSP form tags and so on. In struts.xml, for file upload section, I have:

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

Solution

  • The version of Struts should be updated due to WW-4466.

    With WW-3025 there was a new config constant introduced: struts.multipart.bufferSize

    Currently it is set as required and hence applications must specify it. The default value is always overridden.

    -> should be required = false

    Fix Version/s: 2.3.24