在某些情况下,RESTClient实例在Groovy服务中为null

问题描述

我正在使用grails 2.4.0。

在resources.groovy中-

oauthRestClient(wslite.rest.RESTClient) {
        println Holders.config."$Holders.config.citruspay.consumerPortal.env".oAuth.baseURL
        url =  Holders.config."$Holders.config.citruspay.consumerPortal.env".oAuth.baseURL             
httpClient = ref('oauthHttpClient')
    }

在服务文件UserProfileService.groovy中-一种新定义的方法-

class UserProfileService {

    def oauthRestClient

def getAccountdisabledStatusDummy(String owner) {
        log.info("In getAccountdisabledStatus Service for owner ")
        log.info("*****************************************")

        def restClient = oauthRestClient

        log.info "restClient in getAccountdisabledStatusDummy "+restClient
        
    }

这由SomeController.groovy文件调用-

class SomeController {

    def userProfileService
    
    def checkUser(){
    ..
        def disableResponse = userProfileService.getAccountdisabledStatusDummy(userId)

    ..
    }
}

这是Ajax从gsp文件调用的。

输出-

restClient显示为空。

我尝试通过现有服务方法中的复制粘贴进行操作,但未成功。即使当一个UserProfileService method1()调用在checkUser内的同一流程中运行正常时,如果我将其复制到method2()并稍后调用,它也可以在第一个AJAX调用中工作,然后在第二个调用中给出null。

第一次通话-

getAccountdisabledStatusDummy中的restclient wslite.rest.RESTClient@6b319ef3

第二次通话-

getAccountdisabledStatusDummy中的restclient null

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)