Quantcast

Problems with export plugin and mime types

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Problems with export plugin and mime types

mpermar
Hi guys,

I'm just facing a weird problem with the export plugin. An important note is I'm using grails 1.0.5. My code is pretty simple and pretty much what you can find in the docs:

    def index = {        

        if(!params.max) params.max = 10
        def metadata = []
       
        if(params?.format && params.format != "html"){
            def user = session.user
            metadata = cvMetadataService.exportMetadata(user)
            response.contentType = ConfigurationHolder.config.grails.mime.types[params.format]
            response.setHeader("Content-disposition", "attachment; filename=data.${params.format}")
           
            List fields = ["name"]
            Map labels = ["name": "Name"]

            exportService.export(params.format, response.outputStream,metadata, fields,labels,[:], [:])
            response.outputStream.flush()
            return
        }

        [metadataInstanceList:metadata,total:10]
    }

The weird thing is that the first time I invoke this method from my export page it works fine and file gets exported. But on subsequent times the system does not work and even worse the controller method does not get invoked. Can read the following exception in the logs:

2010-feb-23 11:48:50,912 mortbay.log Nested in org.springframework.web.util.NestedServletException: Request processing f
ailed; nested exception is org.codehaus.groovy.runtime.metaclass.MethodSelectionException: Could not find which method <
init>() to invoke from this list:
  public org.codehaus.groovy.grails.web.mime.MimeType#<init>(java.lang.String)
  public org.codehaus.groovy.grails.web.mime.MimeType#<init>(java.lang.String, java.util.Map):
org.codehaus.groovy.runtime.metaclass.MethodSelectionException: Could not find which method <init>() to invoke from this
 list:
  public org.codehaus.groovy.grails.web.mime.MimeType#<init>(java.lang.String)
  public org.codehaus.groovy.grails.web.mime.MimeType#<init>(java.lang.String, java.util.Map)
        at groovy.lang.MetaClassImpl.chooseMethod(MetaClassImpl.java:2423)
        at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1265)
        at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1185)
        at groovy.lang.ExpandoMetaClass.invokeConstructor(ExpandoMetaClass.java:524)
        at org.codehaus.groovy.runtime.InvokerHelper.invokeConstructorOf(InvokerHelper.java:809)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeNewN(ScriptBytecodeAdapter.java:230)
        at org.codehaus.groovy.grails.web.mime.MimeType.getConfiguredMimeTypes(MimeType.groovy:67)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
        at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1105)
        at groovy.lang.ExpandoMetaClass.invokeStaticMethod(ExpandoMetaClass.java:957)
        at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:749)


Any ideas?

Thanks,
--
Martín Pérez

Founder,
http://www.jobsket.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Problems with export plugin and mime types

desperado2.inchd
This post has NOT been accepted by the mailing list yet.
grails.mime.file.extensions = true // enables the parsing of file extensions from URLs into the request format
grails.mime.use.accept.header = false
grails.mime.types = [html: ['text/html', 'application/xhtml+xml'],
        xml: ['text/xml', 'application/xml'],
        text: 'text/plain',
        js: 'text/javascript',
        rss: 'application/rss+xml',
        atom: 'application/atom+xml',
        css: 'text/css',
        csv: 'text/csv',
        pdf: 'application/pdf',
        rtf: 'application/rtf',
        excel: 'application/vnd.ms-excel',
        ods: 'application/vnd.oasis.opendocument.spreadsheet',
        all: '*/*',
        json: ['application/json', 'text/json'],
        form: 'application/x-www-form-urlencoded',
        multipartForm: 'multipart/form-data'
]


These entries should be there in the config.groovy. If these are not It'll give you this error.
Thanks.
Main Pal
Main Pal
Loading...