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

  • #16
    So you created separate properties in the domain object to get hold of the name and type of file.

    Good, I tried this and it works fine.
    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.
    Is it required to wrap my action inside the transition itself?
    As i said in my last post, that from the view-state I navigate to the action-state where I invoke this action to upload my file.

    Anyway, it works fine now.. the problem was with the multipart form.

    Thanks a lot for the suggestions.


    • #17
      Glad that helped you. What I was suggesting was to use only the view state and put your upload logic in the view state transition subelement:
      <view-state id="uploadVIew" model="myBean">
        <transition on="yourUploadEvent" to="success">
          <evaluate expression="myFormAction.fileUpload(myBean)"/>
      Doing that way your method fileUpload() will be called after the binding and in the same request so you can use directly the MultipartFile (like you did in your original code). The difference between this approach (with only the view) and your original approach (with a view and an action state) is that when you execute the action state you are in a different request than the first one (because of the redirect after post that the swf is doing under the scene). Because of that the multipartFile member has to be serialized and there appears to be the problem. If you specify it as transient it will not be serialized and when you'll access it in your method you'll get a nullpointer. So in order to get rid of the problem you have to avoid the serialization (specify transient on the multipartFile) and you have to access it when it has the value, in the first request (put your upload code in the view state like I said before).
      I have a tendency to be verbose because english is not my native language. Hope that I was clear enough.


      • #18
        a little more information...

        I am having the same issue...and like deep says the file still get uploaded.

        org.springframework.webflow.execution.repository.FlowExecutionRestorationFailureException: A problem occurred restoring the flow execution with key 'e1s5'
        	at org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshotFactory.restoreExecution(
        	at org.springframework.webflow.execution.repository.snapshot.AbstractSnapshottingFlowExecutionRepository.restoreFlowExecution(
        	at org.springframework.webflow.execution.repository.impl.DefaultFlowExecutionRepository.getFlowExecution(
        	at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(
        	at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(
        	at org.springframework.webflow.mvc.servlet.FlowController.handleRequest(
        	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(
        	at org.springframework.web.servlet.DispatcherServlet.doDispatch(
        	at org.springframework.web.servlet.DispatcherServlet.doService(
        	at org.springframework.web.servlet.FrameworkServlet.processRequest(
        	at org.springframework.web.servlet.FrameworkServlet.doGet(
        	at javax.servlet.http.HttpServlet.service(
        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(
        	at org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshotFactory.restoreExecution(
        Caused by: C:\dev\apps\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\mobolus\upload_c82342c_11aef8b3cda__8000_00000005.tmp (The system cannot find the file specified)
        	at Method)
        	at org.apache.commons.fileupload.disk.DiskFileItem.readObject(
        As seen in the last stacktrace, it looks like there is some kind of error in the adObject()

        I tried searching for this issue but I it seems its related to webflow in some way. I am not sure how to proceed.


        • #19
          Sorry I missed page 2. I didn't see that you had already resolved this.

          Originally posted by DeepEdward View Post
          Anyway, it works fine now.. the problem was with the multipart form.
          Please explain this. What did you do to fix the multipart form.


          • #20
            Ok, nevermind...somebody (me) needs to read a little more carefully and not skim so much. I will try it out.


            • #21
              Thanks fanfy for the explanation as it gave me a better approach to this.

              And your being verbose is good as it gave a detailed explanation



              • #22
                Originally Posted by testing123
                I am having the same issue...and like deep says the file still get uploaded.
                Have a look at the previous posts.. thats gonna help you out..


                • #23
                  Thanks fanfy!

                  I had this same problem. Your explanation was good - and the solution worked for me too.


                  • #24

                    public void fileUpload(Object command) {
          "FILE UPLOAD");
                    String dir = "z://FileUpload//File_Repository//";
                    try {
                    byte buf[] = new byte[1024 * 4];
                    Portfolio bean = (Portfolio) command;

                    new File(dir).mkdirs();
          "Creating Directory");

                    File file = new File(dir, bean.getFile().getOriginalFilename());

                    FileOutputStream output = new FileOutputStream(file);

                    try {
                    InputStream input = bean.getFile().getInputStream();
                    try {
                    while (true) {
                    int count =;
                    if (count == -1) {
                    output.write(buf, 0, count);
                    } finally {
                    } finally {
                    } catch (Exception e) {


                    • #25
                      Thanks!!! The suggested appraoch helped me to resolve the file (PDF) upload issue using webflow.


                      • #26
                        Solved for us

                        The issue was solved when we set bind="false" on transition state.


                        • #27
                          Check this link first for simple upload file
                          Then Multi Part