spring-webflow
spring-webflow copied to clipboard
Trying to deserialize the flow execution from the uploaded file [SWF-1083]
John Mikich opened SWF-1083 and commented
(Forum posts 54466 and 62542) Uploading a file using Commons FileUpload as provided with Spring 2.5.6 with Webflow 2.0.6. Strictly per Spring Reference chapter 13.8 (http://static.springframework.org/spring/docs/2.5.x/reference/mvc.html#mvc-multipart), I am utilizing the third option when uploading the file, i.e. "The third (and final) option is where one binds directly to a MultipartFile property declared on the (form backing) object's class. In this case one does not need to register any custom PropertyEditor because there is no type conversion to be performed.".
Here is my multipart resolver:
<!---- Multipart (file upload) resolver for Commons FileUpload. --> <bean id="portletMultipartResolver" class="org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver"> <!-- one of the properties available; the maximum file size in bytes --> <property name="maxUploadSize" value="10485760"/> </bean>
The file uploads fine, however, then I get:
org.springframework.webflow.execution.repository.snapshot.SnapshotUnmarshalException: IOException thrown deserializing the flow execution stored in this snapshot -- this should not happen! ... Caused by: java.io.FileNotFoundException: /usr/WebSphere/AppServer/temp/jadws211/WebSphere_Portal/Vendor_Com_nce_Portal_PA_1_0_77A/vcportlet.war/upload_346f083a_120338c0f30_3217_00000006.tmp (A file or directory in the path name does not exist.)
Somehow, the webflow is attempted to be deserialized from the uploaded file, as seen above!? The uploaded file was previously deleted with transferTo(.) method.
Why has the webflow tried to be deserialized from the uploaded file?
Affects: 2.0.6
Reference URL: http://forum.springsource.org/showthread.php?t=62542
2 votes, 0 watchers
Keith Donald commented
If you are binding to a flow-scoped bean that flow-scoped bean will be serialized when the flow pauses, then deserialized when the flow is restored. Can the Multipart object be serialized and deserialized successfully? You might consider converting the multipart to a byte[] during the binding process using a converter.
John Mikich commented
My flow-scoped model bean is serializable and the Multipart object used is CommonsMultipartFile which is serializable as well, therefore, it should be serialized and deserialized successfully. The point is that suggested way of uploading a file from the Reference Manual (chapter 13.8) as cited in my previous posting is not working. Are you suggesting that I should abandon the technique of uploading with Multipart object and not use its transferTo(.) method? If so, why is it suggested in the Reference Manual? Or I am missing something important here? I like this technique since the upload works perfectly and exactly the way I want it (I can copy the uploaded file to the specific location on the server).
Keith Donald commented
I'm simply suggesting that serialization and subsequent deserialization of the Multipart object may be causing this problem. You might try writing a unit test that tries to serialize and deserialize this object to see if you can reproduce it locally.
Barry commented
I'm getting the same error, also using the third approach. I turned the logging level to debug on org.springframework.web.multipart.commons, and noticed this happening:
First, after uploading the file, it is saved: DEBUG (CommonsFileUploadSupport.java:258) - Found multipart file [file] of size 32768 bytes with original filename [test.xls], stored at [C:\Temp\filename.tmp]
Then, the DispatcherServlet deletes it by calling this: multipartResolver.cleanupMultipart((MultipartHttpServletRequest) request); giving this log message: DEBUG (CommonsFileUploadSupport.java:278) - Cleaning up multipart file [file] with original filename [test.xls], stored at [C:\Temp\filename.tmp]
Finally, when SWF tries to deserialize the flow, it throws the error because the file isn't there anymore: SnapshotUnmarshalException: IOException thrown deserializing the flow execution stored in this snapshot -- this should not happen! Caused by: FileNotFoundException: C:\Temp\filename.tmp (The system cannot find the file specified)
I'm using SWF 2.0.8.RELEASE. Getting the same error in jetty & tomcat. Java 1.6.0_07. I've shortened the filename here for brevity, but it was identical in each case.
If I bind using a ByteArrayMultipartFileEditor, and converting to a byte[] it works fine, but I'd prefer to be able to bind to a MultipartFile directly.
Barry commented
It would seem that the file is prematurely deleted - I rigged up my own DispatcherServlet, commenting out this :
// Clean up any resources used by a multipart if (processedRequest != request) cleanupMultipart(processedRequest); }
and it worked without issue (although now I think these MultipartFiles will start cluttering up my Temp dir).
Barry commented
I see that this issue has already been discussed here: http://forum.springsource.org/showthread.php?t=54466 where several other workarounds were suggested. Still it does seem like a bug, though certainly not a major one.
org.springframework.web.multipart.commons.CommonMultipartResolver not found in spring 6.0.11 what is solution for file uploading in spring mvc ????