grails项目中的ClassCastException

时间:2015-10-16 12:49:43

标签: java rest grails groovy

我在grails项目中遇到了ClassCastException的一些问题。 我不知道它有什么问题。

2015-10-16 14:07:19 | http-bio-8096-exec-10 | ERROR | org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver | ClassCastException occurred when processing request: [POST] /gci/m-t
fr.xxx.use.gci.consumer.rest.MTService cannot be cast to fr.xxx.use.gci.consumer.rest.MTService. Stacktrace follows:
java.lang.ClassCastException: fr.xxx.use.gci.consumer.rest.MTService cannot be cast to fr.xxx.use.gci.consumer.rest.MTService
    at fr.xxx.use.gci.MTController$$EPRHJ9I6.save(MTController.groovy:26)
    at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
    at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
    at fr.xxx.xxxxx.authentication.AnnuaireCredentialCheckerFilter.doFilter(AnnuaireCredentialCheckerFilter.groovy:84)
    at fr.xxx.xxxxx.security.mock.MockAuthenticationFilter.doFilter(MockAuthenticationFilter.groovy:60)
    at com.granicus.grails.plugins.cookiesession.CookieSessionFilter.doFilterInternal(CookieSessionFilter.java:78)
    at fr.xxx.use.navigation.NexturlValidationFilter.doFilter(NexturlValidationFilter.groovy:52)
    at fr.xxx.use.requestid.RequestIdFilter.doFilter(RequestIdFilter.groovy:38)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

所以,这是我的控制器

class MTController {

def mTService

def index() {
    render view:'index'
}

def save(){
    def flux = request.JSON

    if (!flux.numCT || !flux.numST) {
        render status: HttpServletResponse.SC_BAD_REQUEST
        return
        }

    def bddId = mTService.saveInfos(flux.numCT, flux.numST)
    if (bddId == null) {
        render status: HttpServletResponse.SC_BAD_REQUEST
        return
    }
}

这是我的服务

class MTService {

def saveInfos(numCT, numST) {
    def mTOTD = new InitMT()

    mTOTD.numCT = numCT
    mTOTD.numST = numST
    return mTOTD.save()
}

}

1 个答案:

答案 0 :(得分:1)

grails clean很可能会解决此问题。错误是如此奇怪我怀疑正在运行的代码不是您认为正在运行的代码。