Announcement Announcement Module
Collapse
No announcement yet.
Multipart File Upload Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multipart File Upload

    Hi,
    I have tried the multipart file upload with spring webMVC which works fine there.
    On integrating the same with webflow it works fine, but when i exceed the file size limit then i get the error :






    Code:
    exception 
    
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.webflow.execution.repository.FlowExecutionRestorationFailureException: A problem occurred restoring the flow execution with key '_cF37DB186-50C5-DA7E-260C-E004FE3A5DB1_k0C073EB1-5D91-1D07-F325-57DF2CB18565'; nested exception is org.springframework.webflow.execution.repository.continuation.ContinuationUnmarshalException: IOException thrown deserializing the flow execution stored in this continuation -- this should not happen!; nested exception is java.io.FileNotFoundException: D:\Deep\PBA040907\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\PA_1.0\upload__74ae0d4b_11a0141e397__8000_00000000.tmp (The system cannot find the file specified)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:488)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:431)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    
    org.springframework.webflow.execution.repository.FlowExecutionRestorationFailureException: A problem occurred restoring the flow execution with key '_cF37DB186-50C5-DA7E-260C-E004FE3A5DB1_k0C073EB1-5D91-1D07-F325-57DF2CB18565'; nested exception is org.springframework.webflow.execution.repository.continuation.ContinuationUnmarshalException: IOException thrown deserializing the flow execution stored in this continuation -- this should not happen!; nested exception is java.io.FileNotFoundException: D:\Deep\PBA040907\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\PA_1.0\upload__74ae0d4b_11a0141e397__8000_00000000.tmp (The system cannot find the file specified)
    	org.springframework.webflow.execution.repository.continuation.ContinuationFlowExecutionRepository.getFlowExecution(ContinuationFlowExecutionRepository.java:153)
    	org.springframework.webflow.executor.FlowExecutorImpl.refresh(FlowExecutorImpl.java:253)
    	org.springframework.webflow.executor.support.FlowRequestHandler.handleFlowRequest(FlowRequestHandler.java:117)
    	org.springframework.webflow.executor.mvc.FlowController.handleRequestInternal(FlowController.java:165)
    	org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
    	org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:874)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:808)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:431)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    
    
    root cause 
    
    java.io.FileNotFoundException: D:\Deep\PBA040907\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\PA_1.0\upload__74ae0d4b_11a0141e397__8000_00000000.tmp (The system cannot find the file specified)
    	java.io.FileInputStream.open(Native Method)
    	java.io.FileInputStream.<init>(Unknown Source)
    	org.apache.commons.fileupload.disk.DiskFileItem.readObject(DiskFileItem.java:691)
    	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	java.lang.reflect.Method.invoke(Unknown Source)
    	java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
    	java.io.ObjectInputStream.readSerialData(Unknown Source)
    	java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    	java.io.ObjectInputStream.readObject0(Unknown Source)
    	java.io.ObjectInputStream.defaultReadFields(Unknown Source)
    	java.io.ObjectInputStream.readSerialData(Unknown Source)
    	java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    	java.io.ObjectInputStream.readObject0(Unknown Source)
    	java.io.ObjectInputStream.defaultReadFields(Unknown Source)
    	java.io.ObjectInputStream.readSerialData(Unknown Source)
    	java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    	java.io.ObjectInputStream.readObject0(Unknown Source)
    	java.io.ObjectInputStream.readObject(Unknown Source)
    	java.util.HashMap.readObject(Unknown Source)
    	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	java.lang.reflect.Method.invoke(Unknown Source)
    	java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
    	java.io.ObjectInputStream.readSerialData(Unknown Source)
    	java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    	java.io.ObjectInputStream.readObject0(Unknown Source)
    	java.io.ObjectInputStream.defaultReadFields(Unknown Source)
    	java.io.ObjectInputStream.defaultReadObject(Unknown Source)
    	org.springframework.webflow.core.collection.LocalAttributeMap.readObject(LocalAttributeMap.java:307)
    	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	java.lang.reflect.Method.invoke(Unknown Source)
    	java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
    	java.io.ObjectInputStream.readSerialData(Unknown Source)
    	java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    	java.io.ObjectInputStream.readObject0(Unknown Source)
    	java.io.ObjectInputStream.readObject(Unknown Source)
    	org.springframework.webflow.engine.impl.FlowSessionImpl.readExternal(FlowSessionImpl.java:141)
    	java.io.ObjectInputStream.readExternalData(Unknown Source)
    	java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    	java.io.ObjectInputStream.readObject0(Unknown Source)
    	java.io.ObjectInputStream.readObject(Unknown Source)
    	java.util.LinkedList.readObject(Unknown Source)
    	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	java.lang.reflect.Method.invoke(Unknown Source)
    	java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
    	java.io.ObjectInputStream.readSerialData(Unknown Source)
    	java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    	java.io.ObjectInputStream.readObject0(Unknown Source)
    	java.io.ObjectInputStream.readObject(Unknown Source)
    	org.springframework.webflow.engine.impl.FlowExecutionImpl.readExternal(FlowExecutionImpl.java:486)
    	java.io.ObjectInputStream.readExternalData(Unknown Source)
    	java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    	java.io.ObjectInputStream.readObject0(Unknown Source)
    	java.io.ObjectInputStream.readObject(Unknown Source)
    	org.springframework.webflow.execution.repository.continuation.SerializedFlowExecutionContinuation.deserialize(SerializedFlowExecutionContinuation.java:186)
    	org.springframework.webflow.execution.repository.continuation.SerializedFlowExecutionContinuation.unmarshal(SerializedFlowExecutionContinuation.java:93)
    	org.springframework.webflow.execution.repository.continuation.ContinuationFlowExecutionRepository.getFlowExecution(ContinuationFlowExecutionRepository.java:149)
    	org.springframework.webflow.executor.FlowExecutorImpl.refresh(FlowExecutorImpl.java:253)
    	org.springframework.webflow.executor.support.FlowRequestHandler.handleFlowRequest(FlowRequestHandler.java:117)
    	org.springframework.webflow.executor.mvc.FlowController.handleRequestInternal(FlowController.java:165)
    	org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
    	org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:874)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:808)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:431)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    I googled it and found that this had been reported as a bug,
    (see link, http://jira.springframework.org/browse/SWF-212)

    Please lemme know if this is fixed? or any way out for this issue?

    Rgds,
    Deep
    Last edited by DeepEdward; May 19th, 2008, 09:20 AM.

  • #2
    Haven't come across a single answer to file upload yet, is there any fix for this?
    On upgrading my Spring webflow jar, i get the error as specified in the thread(http://forum.springframework.org/showthread.php?t=54462). I am currently using version 1.0.5

    Pls give a solution for this, if anyone came across this.

    Regards,
    DeepEdward

    Comment


    • #3
      Multipart File Upload with Spring-Webflow-2.0.2

      Hi,

      I have upgraded my Spring Webflow Jars from 1.0.5 to 2.0.2, and the Spring jar to 2.5.5.

      Uploading the file using the previous version of webflow was not working for me, but the same worked when using just spring web mvc.

      Now on upgrading the webflow jar, I am getting the following Exception:

      Code:
      SEVERE: Servlet.service() for servlet pa threw exception
      org.springframework.webflow.execution.repository.FlowExecutionRestorationFailureException: A problem occurred restoring the flow execution with key 'e2s16'
      	at org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshotFactory.restoreExecution(SerializedFlowExecutionSnapshotFactory.java:82)
      	at org.springframework.webflow.execution.repository.snapshot.AbstractSnapshottingFlowExecutionRepository.restoreFlowExecution(AbstractSnapshottingFlowExecutionRepository.java:89)
      	at org.springframework.webflow.execution.repository.impl.DefaultFlowExecutionRepository.getFlowExecution(DefaultFlowExecutionRepository.java:104)
      	at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:152)
      	at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:173)
      	at org.springframework.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:172)
      	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
      	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
      	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
      	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
      	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
      	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
      	at java.lang.Thread.run(Unknown Source)
      Caused by: org.springframework.webflow.execution.repository.snapshot.SnapshotUnmarshalException: IOException thrown deserializing the flow execution stored in this snapshot -- this should not happen!
      	at org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshot.unmarshal(SerializedFlowExecutionSnapshot.java:100)
      	at org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshotFactory.restoreExecution(SerializedFlowExecutionSnapshotFactory.java:80)
      	... 26 more
      Caused by: java.io.FileNotFoundException: D:\Deep\PBA040907\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\PA_1.2\upload_511f353d_11ae3b9e380__8000_00000004.tmp (The system cannot find the file specified)
      	at java.io.FileInputStream.open(Native Method)
      	at java.io.FileInputStream.<init>(Unknown Source)
      	at org.apache.commons.fileupload.disk.DiskFileItem.readObject(DiskFileItem.java:691)
      	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 java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
      	at java.io.ObjectInputStream.readSerialData(Unknown Source)
      	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      	at java.io.ObjectInputStream.readObject0(Unknown Source)
      	at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
      	at java.io.ObjectInputStream.readSerialData(Unknown Source)
      	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      	at java.io.ObjectInputStream.readObject0(Unknown Source)
      	at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
      	at java.io.ObjectInputStream.readSerialData(Unknown Source)
      	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      	at java.io.ObjectInputStream.readObject0(Unknown Source)
      	at java.io.ObjectInputStream.readObject(Unknown Source)
      	at java.util.HashMap.readObject(Unknown Source)
      	at sun.reflect.GeneratedMethodAccessor209.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
      	at java.io.ObjectInputStream.readSerialData(Unknown Source)
      	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      	at java.io.ObjectInputStream.readObject0(Unknown Source)
      	at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
      	at java.io.ObjectInputStream.defaultReadObject(Unknown Source)
      	at org.springframework.webflow.core.collection.LocalAttributeMap.readObject(LocalAttributeMap.java:331)
      	at sun.reflect.GeneratedMethodAccessor208.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
      	at java.io.ObjectInputStream.readSerialData(Unknown Source)
      	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      	at java.io.ObjectInputStream.readObject0(Unknown Source)
      	at java.io.ObjectInputStream.readObject(Unknown Source)
      	at org.springframework.webflow.engine.impl.FlowSessionImpl.readExternal(FlowSessionImpl.java:147)
      	at java.io.ObjectInputStream.readExternalData(Unknown Source)
      	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      	at java.io.ObjectInputStream.readObject0(Unknown Source)
      	at java.io.ObjectInputStream.readObject(Unknown Source)
      	at java.util.LinkedList.readObject(Unknown Source)
      	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 java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
      	at java.io.ObjectInputStream.readSerialData(Unknown Source)
      	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      	at java.io.ObjectInputStream.readObject0(Unknown Source)
      	at java.io.ObjectInputStream.readObject(Unknown Source)
      	at org.springframework.webflow.engine.impl.FlowExecutionImpl.readExternal(FlowExecutionImpl.java:503)
      	at java.io.ObjectInputStream.readExternalData(Unknown Source)
      	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      	at java.io.ObjectInputStream.readObject0(Unknown Source)
      	at java.io.ObjectInputStream.readObject(Unknown Source)
      	at org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshot.deserialize(SerializedFlowExecutionSnapshot.java:193)
      	at org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshot.unmarshal(SerializedFlowExecutionSnapshot.java:98)

      Has anyone come across this issue...
      Please let me know if there are some more changes to be done to implement the multipart upload functionality with SpringWebflow2.0.2

      DeepEdward
      Last edited by DeepEdward; Jul 2nd, 2008, 08:07 AM.

      Comment


      • #4
        Is there a way to solve this..
        I am stuck with this problem.
        It seems that the apache commons-fileupload jar tries to clear the file to be uploaded(which it cannot find in the temp folder), and throws the FileNotFoundException.

        Please let me know if this can be resolved, as uploading is a very important feature for me.

        Comment


        • #5
          I think your problem is related to an error in the binding process. Swf2 is not using mvc for binding request parameters to properties in the model and they have a problem related to binding MultipartFile parameters. See this post and let me know if helped you.

          http://forum.springframework.org/sho...ight=multipart

          Comment


          • #6
            If the problem would have been in the binding process then I think the File to be uploaded, would not have uploaded at all.

            On changing the property to byte array type as specified in your post, I get the same exception. The problem I am facing here is, if the file is a small text file, it gets uploaded without any exception.

            But when the file to be uploaded is big in size (like a pdf file or a video file) then I get this error. Though, this exception is thrown in this case, the file gets uploaded.

            I think the problem is the commons-fileupload jar used by spring, which tries to clean up the temp folder for the specified file, on which it throws this error.
            Last edited by DeepEdward; Jul 3rd, 2008, 05:01 AM.

            Comment


            • #7
              This type of exception I've seen sometime ago and in my case was related to the binding mechanism. After using the MultipartFile as property type in the model the problem disappeared. Today I've modified my code to simulate this scenario but it didn't worked. I also tried to upload a 14 mb file in my application and worked without a problem. I don't know what to say to you. If your application worked with mvc you can use the old binding style in swf2 as a workaround: use a custom FormAction, register a MultipartFile editor to byte[] and call it manually in your flow: <evaluate expression="yourFormAction.bind(flowRequestContext )" />. Hope that helps.

              Comment


              • #8
                sorry for not reading your entire message. it seems that you had the same problem with swf1 also. please ignore my earlier advice.

                Comment


                • #9
                  Can you post the flow section related to handling the upload file?

                  Comment


                  • #10
                    whole file upload operation using spring webflow2.0.2

                    Hi,

                    JSP Page:

                    Code:
                    <form:form commandName="myBean"  method="post" enctype="multipart/form-data">
                    <input name="file" type="file" />
                    </form:form>
                    FormBacking Object: I have a multipart type property:with getters and setters

                    FormAction Class: In my form action class i have the method to upload the file

                    Code:
                    public void fileUpload(Object command) {
                    		log.info("FILE UPLOAD");
                    		String dir = "z://FileUpload//File_Repository//";
                    		try {
                    			byte buf[] = new byte[1024 * 4];
                    			Portfolio bean = (Portfolio) command;
                    			
                    			new File(dir).mkdirs();
                    			log.info("Creating Directory");
                    
                    			File file = new File(dir, bean.getFile().getOriginalFilename());
                    			
                    			FileOutputStream output = new FileOutputStream(file);
                    			output.write(bean.getFile().getBytes());
                    
                    			try {
                    				InputStream input = bean.getFile().getInputStream();
                    				try {
                    					while (true) {
                    						int count = input.read(buf);
                    						if (count == -1) {
                    							break;
                    						}
                    						output.write(buf, 0, count);
                    					}
                    				} finally {
                    					input.close();
                    				}
                    			} finally {
                    				output.close();
                    			}
                    		} catch (Exception e) {
                    			e.printStackTrace();
                    		}
                    	}
                    In the -servlet.xml file I have specified the multipartResolver

                    Code:
                    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
                    		    	  <property name="maxUploadSize" value="90000000"/>
                    </bean>
                    flow.xml file


                    Code:
                    <webflow:action-state id="fileUpload">
                    		<webflow:evaluate
                    				expression="myFormAction.fileUpload(flowScope.myBean)" />
                    		<webflow:transition on="success" to="indexPage" />
                    		<webflow:transition on="error" to="errorPage" />
                    </webflow:action-state>
                    The exception thrown is the same as i mentioned above.(i.e. FileNotFound exception) but the file gets uploaded, whatever the size is.

                    Duh,I think i haven't missed out anything,as the same worked for me when i used spring-web-mvc.
                    In case there are some more configurations required please give a pointer.

                    Deep

                    Comment


                    • #11
                      Hi,

                      I'm using the file upload from Tomahawk with spring webflow2.0.2 and Facelets. I don't get any exception and indeed files get uploaded, whatever the size is!

                      Comment


                      • #12
                        Your base is JSF with which you are using Spring Webflow, whereas I am using Spring WebMVC as my base and Spring Webflow ion top of that.

                        The same worked out for me when I was using onle SpringWebMVC, but when I integrated my application with Spring Webflow, the feature is not well supported.

                        Comment


                        • #13
                          I don't see the view state. My first suggestion is to try to put your custom action state directly in view's transition and see what happens(that way you will process the MultipartFile in the original request):

                          Code:
                          <webflow:view-state id="yourView" model="myBean">
                            <webflow:on-render>
                            ... your render code 
                            </webflow:on-render>
                            <webflow:transition on="uploadEvent" to="success">
                               <webflow:evaluate expression="myFormAction.fileUpload(flowScope.myBean)" />
                            </webflow:transition>
                          </webflow:view-state>
                          Anyway, my advice is to get rid of the MultipartFile as soon as you can. So set the MultipartFile as transient in your command object and in the setter extract all the needed properties (originalFileName, content as a byte array) and set other properties in your command with these values.

                          Comment


                          • #14
                            I had copied the relevant section from my flow section as in the view-state, I just have a transition which navigates to the action-state,performs the action and on "success" returns back the same view state..

                            Anyway, my advice is to get rid of the MultipartFile as soon as you can. So set the MultipartFile as transient in your command object and in the setter extract all the needed properties (originalFileName, content as a byte array) and set other properties in your command with these values.
                            (1)Now as you said, to put the Multipart file as transient, then in doing so,I get a NullPointException.
                            (2) Getting the multipart file and setting to the byte[] is fine, but other properties such as originalFileName,contentType etc. how do you set them.

                            Is there any other way to implement this, do give some suggestions.
                            Can we make use of the SimpleFormAction(SpringMVC Controllers) from inside the webflow?
                            Last edited by DeepEdward; Jul 4th, 2008, 08:15 AM.

                            Comment


                            • #15
                              I'm not sure from your post if you tried to eliminate the action state and use only the view state doing the upload logic in the view transition? (see my earlier post).

                              I don't understand your null pointer exception. It's probably because later you are trying to use the multipart property in your action state. My point is to get rid of the multipart, something like this:

                              Code:
                              public class MyBean implements Serializable {
                               private byte[] fileContent;
                               private String fileContentType;
                               private String originalFileName;
                               
                               // getters and setters for filecontent, fileCOntentType, originalFileName
                              
                                public void setFile(MultipartFile file) {
                                  this.fileContent = file.getBytes();
                                  this.fileContentType = file.getContentType();
                                  this.originalFileName = file.getOriginalFileName();
                                }  
                              }
                              Your upload login from your action method will use the myBean.getFileCOntent, myBean.getOriginalFileName and myBean.getFileContentType() instead of multipart file property which doesn't exist anymore.

                              When the swf will try to bind the request parameter of type MultipartFile will use the setFile(...) method from your bean.

                              But I really think you should first try my earlier suggestion: eliminate the action state and put the <evaluate .../> upload logic directly in the view-state transition.

                              Comment

                              Working...
                              X