POST请求中的Grails NotSerializableException

时间:2014-06-13 08:32:09

标签: java spring exception grails serialization

我在尝试运行我的grails应用程序时不断收到此错误,任何人都可以告诉可能是什么问题。

以下是导致此错误的控制器方法,它通过视图中select的ajax调用获取其参数。

    def optionsBySelection()
        {
            log.error "hej11 ${params}"
            Sql sql = new Sql(dataSource)
            Map query = [params: params]
                def optSelection = sql.rows("select distinct :params from log_entry",query).each { row->
                    log.error "hej22 ${row}"
            }

                render (template: "selection" , model: [optSelection]) as JSON
}




ERROR errors.GrailsExceptionResolver  - NotSerializableException occurred when processing request: [POST] /admin/optionsBySelection - parameters:
params: host
org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap. Stacktrace follows:
Message: org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap
    Line | Method
->> 1183 | writeObject0          in java.io.ObjectOutputStream
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    347 | writeObject           in     ''
|   4401 | setSerializableObject in com.mysql.jdbc.PreparedStatement
|   4083 | setObject             in     ''
|    169 | setObject . . . . . . in org.apache.commons.dbcp.DelegatingPreparedStatement
|     34 | optionsBySelection    in se.su.it.monitor.AdminController
|    195 | doFilter . . . . . .  in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|     63 | doFilter              in grails.plugin.cache.web.filter.AbstractFilter
|   1145 | runWorker . . . . . . in java.util.concurrent.ThreadPoolExecutor
|    615 | run                   in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run . . . . . . . . . in java.lang.Thread

1 个答案:

答案 0 :(得分:0)

您正在尝试将整个GrailsParameterMap实例放入准备好的SQL查询中。您不能这样做,而应该创建一个新映射,其中包含要传递给SQL查询的参数子集。