package com.lk
class Stock {
static expose = 'stock'
long id
String symbol
String name
BigDecimal price
long sharevolume
long tradevolume
Float turnover
BigDecimal change
BigDecimal changePercentage
long quantity
/*Float open*/
Float hiTrade
Float loTrade
Date tradesTransacttime
Float previousClose
static mapping = {
table 'VIEW_CD_TRADE_SUMMARY_NO_DEBT'
version false
autoTimestamp false
}
static api =
[
excludedFields: ["errors", "attached", "properties"],
list: { params ->
if (params.code?.equals('gvt123')) {
if (params.exclude) {
api.excludedFields = ["errors", "attached", "properties"]
params.exclude.split(",").each { api.excludedFields << it?.trim() }
} else {
api.excludedFields = ["errors", "attached", "properties"]
}
//println("params -->("+params)
params.id ? Stock.findAllByIdInList(params.id.split(",").collect { it as long }) : Stock.list(params)
} else {
"Invalid Request"
}
},
count: { params -> if(params.code?.equals('gvt123')) {
params.id ? Stock.countByIdInList(params.id.split(",").collect { it as long }) : Stock.count()
}else{
0
}}
]
}
请查找以上Stock.groovy文件,当我运行它时,我得到以下异常。请帮帮我。
URI /cses/json/stock
Class java.lang.IllegalArgumentException
Message null
有没有办法处理异常检查哪个条目带有故障值。如果需要我也可以添加Oracle View。
堆栈跟踪在
之下java.lang.IllegalArgumentException
at com.lk.Stock$__clinit__closure2.doCall(Stock.groovy:41)
at org.grails.plugins.rest.JsonRestApiController$_closure1.doCall(JsonRestApiController.groovy:14)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at com.brandseye.cors.CorsFilter.doFilter(CorsFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
2014-03-26 09:58:54,463 [http-bio-8080-exec-70] ERROR errors.GrailsExceptionResolver - IllegalArgumentException occurred when processing request: [GET] /cses/json/stock
Stacktrace follows:
java.lang.IllegalArgumentException
at com.lk.Stock$__clinit__closure2.doCall(Stock.groovy:41)
at org.grails.plugins.rest.JsonRestApiController$_closure1.doCall(JsonRestApiController.groovy:14)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at com.brandseye.cors.CorsFilter.doFilter(CorsFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
2014-03-26 09:58:57,676 [http-bio-8080-exec-71] ERROR errors.GrailsExceptionResolver - IllegalArgumentException occurred when processing request: [GET] /cses/json/stock
Stacktrace follows:
java.lang.IllegalArgumentException
at com.lk.Stock$__clinit__closure2.doCall(Stock.groovy:41)
at org.grails.plugins.rest.JsonRestApiController$_closure1.doCall(JsonRestApiController.groovy:14)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at com.brandseye.cors.CorsFilter.doFilter(CorsFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
2014-03-26 10:08:36,170 [http-bio-8080-exec-83] ERROR errors.GrailsExceptionResolver - IllegalArgumentException occurred when processing request: [GET] /cses/json/stock
Stacktrace follows:
java.lang.IllegalArgumentException
at com.lk.Stock$__clinit__closure2.doCall(Stock.groovy:41)
at org.grails.plugins.rest.JsonRestApiController$_closure1.doCall(JsonRestApiController.groovy:14)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at com.brandseye.cors.CorsFilter.doFilter(CorsFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
2014-03-26 10:08:42,807 [http-bio-8080-exec-3] ERROR errors.GrailsExceptionResolver - IllegalArgumentException occurred when processing request: [GET] /cses/json/stock
Stacktrace follows:
java.lang.IllegalArgumentException
at com.lk.Stock$__clinit__closure2.doCall(Stock.groovy:41)
at org.grails.plugins.rest.JsonRestApiController$_closure1.doCall(JsonRestApiController.groovy:14)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at com.brandseye.cors.CorsFilter.doFilter(CorsFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
2014-03-26 10:09:03,060 [http-bio-8080-exec-29] ERROR errors.GrailsExceptionResolver - IllegalArgumentException occurred when processing request: [GET] /cses/json/stock
Stacktrace follows:
java.lang.IllegalArgumentException
at com.lk.Stock$__clinit__closure2.doCall(Stock.groovy:41)
at org.grails.plugins.rest.JsonRestApiController$_closure1.doCall(JsonRestApiController.groovy:14)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at com.brandseye.cors.CorsFilter.doFilter(CorsFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
2014-03-26 10:45:28,004 [http-bio-8080-exec-97] ERROR errors.GrailsExceptionResolver - IllegalArgumentException occurred when processing request: [GET] /cses/json/stock
Stacktrace follows:
java.lang.IllegalArgumentException
at com.lk.Stock$__clinit__closure2.doCall(Stock.groovy:41)
at org.grails.plugins.rest.JsonRestApiController$_closure1.doCall(JsonRestApiController.groovy:14)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at com.brandseye.cors.CorsFilter.doFilter(CorsFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
2014-03-26 10:59:15,551 [http-bio-8080-exec-60] ERROR errors.GrailsExceptionResolver - IllegalArgumentException occurred when processing request: [GET] /cses/json/stock
Stacktrace follows:
java.lang.IllegalArgumentException
at com.lk.Stock$__clinit__closure2.doCall(Stock.groovy:41)
at org.grails.plugins.rest.JsonRestApiController$_closure1.doCall(JsonRestApiController.groovy:14)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at com.brandseye.cors.CorsFilter.doFilter(CorsFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
2014-03-26 13:18:22,183 [http-bio-8080-exec-62] ERROR errors.GrailsExceptionResolver - IllegalArgumentException occurred when processing request: [GET] /cses/json/stock
Stacktrace follows:
java.lang.IllegalArgumentException
at com.lk.Stock$__clinit__closure2.doCall(Stock.groovy:41)
at org.grails.plugins.rest.JsonRestApiController$_closure1.doCall(JsonRestApiController.groovy:14)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at com.brandseye.cors.CorsFilter.doFilter(CorsFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadP...
更新 - 添加堆栈跟踪 谢谢。
答案 0 :(得分:0)
显然,错误发生在你班级的第41行,我认为是:
params.id ? Stock.findAllByIdInList(params.id.split(",").collect { it as long }) : Stock.list(params)
您确定params.id
是由逗号分隔的长串吗?
另请注意,collect
方法会返回java.lang.Long
的列表,而不是您想要的原始long
。为什么不尝试更改java.lang.Long
id
类的Stock
属性? (事实上,我建议总是使用包装类)。