Grails Extjs File Upload
===

I've got a really strange problem. I'm using Extjs and Grails to upload a file to the file system and when I start up the application it doesn't work. But if I go in and edit any code in the controller then magically my file upload works fine. And by any I mean even commenting out a blank line. Here is my ExtJS code:


this._uploadForm =  Ext.create('Ext.form.Panel', { 

/* params are here */

buttons: [{

                text: 'Save',
                handler: function(){
                    var form = this.up('form').getForm();
                    console.log(form);
                    if(form.isValid()){
                        form.submit({
                           url: 'rfto/upload',
                           waitMsg: 'Uploading your file...',
                            success: function() {
                                this.fileUploaded(form)
                            }
                        });
                    }
                } 
...

And here is my grails controller code:

def upload = {

        log.info(params)
        def success, message, name, type
        def f = request.getFile('myFile')
        if(!f.empty) {
            try{
              f.transferTo( new File('/usr/local/apache-tomcat-7.0.14/webapps/prose/js/prose/RFTO' + params.rftoFile + "_" + params.name + '.' + params.fileType) )
              success = true
              message = "File RFTO${params.rftoFile}_${params.name}.${params.fileType} created."
            }
            catch (Exception e) {
               success = false
               message = "Failed to create ${params.name}.${params.fileType}: ${e.message}"
           }
             def ret = [
                success: success,
                name: params.name,
                type: params.fileType
        ]
        renderJSON([
                   ret
           ])
            log.info(message)
        }
    }


When the app first starts up a file upload gives me this:

Resource interpreted as Document but transferred with MIME type application/json: "http://localhost:8080/prose/rfto/upload".

Uncaught Ext.Error: You're trying to decode an invalid JSON String: <pre style="word-wrap: break-word; white-space: pre-wrap;">[{"success":true,"name":"Test","type":"txt"}]</pre>

But any change to my grails controller and suddenly it works fine. The problem is in production I can't go in and change the code every time the server restarts. Any ideas? 