我收到以下错误:
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 844
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 844
| Error 2014-08-28 09:25:11,399 [http-bio-8080-exec-5] ERROR errors.GrailsExceptionResolver - StackOverflowError occurred when processing request: [GET] /api/getProduct - parameters:
id: 14
Stacktrace follows:
Message: Executing action [getProduct] of controller [project.ApiController] caused exception: Runtime error executing action
Line | Method
->> 198 | 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
我的域名如下:
class Product {
String name
String comments
static hasMany = [components:Components]
public asJSON(){
println "product: "+this.id
def builder = new groovy.json.JsonBuilder()
def root = builder {
id this.id
name this.name
comments this.comments
components this.components.collect {it.asJSON()}
}
return builder.toString().replaceAll(/\\"/, '"').replaceAll(/\"\{/,'{').replaceAll(/\}\"/,'}')
}
}
组件:
class Components {
Product part_of
static hasMany = [alternatives:Alternatives]
public String asJSON(){
def builder = new groovy.json.JsonBuilder()
def root = builder {
id this.id
product (this.part_of)?this.part_of.asJSON():null
// alternatives (this.alternatives)?this.alternatives.collect {it.product.productAsJSON()} :null
}
return builder.toString()
}
}
当我执行以下操作时,我得到了异常
Product.get(1).asJSON()
我已经检查过它没有递归调用自己。 产品1有一个Component,它有一个名为part_of的Product实例,它是ID为5的产品