Grails
  1. Grails
  2. GRAILS-3674

upload file failed in "java.lang.IllegalStateException: File has already been moved "

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.0.4
    • Fix Version/s: 1.0.5, 1.1-beta3
    • Component/s: Controllers
    • Labels:
      None
    • Environment:
      jdk 1.6, grails 1.0.4, windows xp, firefox 3.0.4

      Description

      I upgrade my project from grails 1.0.3 to 1.0.4, but it failed in uploading files. I have to revert back to 1.0.3.
      The bug can be reproduced as follow:

      gsp:
      Upload Form: <br/>
      <g:form method="post" enctype="multipart/form-data">
      <input type="file" name="file"/>
      <input type="submit"/>
      </g:form>

      controller:
      def index = {
      if (!params.file) return

      def f=request.getFile('file')
      if (!f.empty)

      { f.transferTo(new File("d:\\tmp\\a.jpg")) render 'transfer ok' }

      else

      { render 'null file' }

      }

      This controller sometimes returns 'transfer ok', but if you try more times, it throws exception:
      Error 200: java.lang.IllegalStateException: File has already been moved - cannot be transferred again
      Servlet: grails
      URI: /testuf/grails/uploader/index.dispatch
      Exception Message: File has already been moved - cannot be transferred again
      Caused by: java.lang.IllegalStateException: File has already been moved - cannot be transferred again
      Class: UploaderController

      In fact, the controller call transferTo() only once. Why the file is moved?

        Activity

        Hide
        James Lau added a comment -

        If I start a new browser, sometimes the controller throws another exception:

        [1149703] errors.GrailsExceptionResolver
        java.lang.NullPointerException
        at java.net.URLDecoder.decode(URLDecoder.java:119)

        Show
        James Lau added a comment - If I start a new browser, sometimes the controller throws another exception: [1149703] errors.GrailsExceptionResolver java.lang.NullPointerException at java.net.URLDecoder.decode(URLDecoder.java:119)
        Hide
        Graeme Rocher added a comment -

        Please attach an app that reproduces the problem

        Show
        Graeme Rocher added a comment - Please attach an app that reproduces the problem
        Hide
        James Lau added a comment -

        The test app is added.
        I run the app with "grails run-app", and then try to upload files, the bug reproduced.

        Show
        James Lau added a comment - The test app is added. I run the app with "grails run-app", and then try to upload files, the bug reproduced.
        Hide
        Jean-Noël Rivasseau added a comment -

        Probably another manifestation of the bug related to multipart forms, that I already reported and is now fixed.

        Show
        Jean-Noël Rivasseau added a comment - Probably another manifestation of the bug related to multipart forms, that I already reported and is now fixed.
        Hide
        Graeme Rocher added a comment -

        Bulk closing bunch of resolved issues

        Show
        Graeme Rocher added a comment - Bulk closing bunch of resolved issues

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            James Lau
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development