CallService throws cannot locate service by name

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

CallService throws cannot locate service by name

Chris Juettner-2
I'm upgrading an old OFBiz based application to the latest Apache version and I discovered a problem with a custom simple method that no longer works.  
I have traced the problem to the CallService class and a change made last year.  I'm not sure of the protocol to open a Jira Tracker but here's the details.

Simple Method declaration:

<simple-method method-name="getDataMaps" short-description="Call a series of services to assemble a map hierarchy" login-required="false">
  <iterate-map map-name="parameters.operationMap" key-name="serviceName" value-name="resultMap">
        <clear-field field-name="serviceMap"/>
        <set-service-fields service-name="${serviceName}" map-name="parameters" to-map-name="serviceMap"/>
        <call-service service-name="${serviceName}" in-map-name="serviceMap">
          <results-to-map map-name="${resultMap}"/>
        </call-service>
        <set field="dataMap.${resultMap}" from-field="${resultMap}"/>
</iterate-map>


When this simple method executes it fails (partial debug log)
2008-01-08 15:40:41,000 (http-0.0.0.0-8443-Processor4) [Log.java:94 :INFO ] *****getDataMaps parameters.operationMap [findProjectDetails=projectDetails, findCustomAttachment=customAttachment]
2008-01-08 15:40:41,000 (http-0.0.0.0-8443-Processor4) [Log.java:94 :INFO ] *****calling service findProjectDetails
2008-01-08 15:40:44,500 (http-0.0.0.0-8443-Processor4) [CallService.java:242:ERROR]
---- exception report ----------------------------------------------------------
Exception: org.ofbiz.service.GenericServiceException
Message: Cannot locate service by name (${serviceName})
---- stack trace ---------------------------------------------------------------
org.ofbiz.service.GenericServiceException: Cannot locate service by name (${serviceName})
org.ofbiz.service.DispatchContext.getModelService(DispatchContext.java:190)
org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:143)
org.ofbiz.minilang.method.callops.CallService.exec(CallService.java:239)
org.ofbiz.minilang.SimpleMethod.runSubOps(SimpleMethod.java:931)


The change is in CallService method exec(MethodContext methodContext) in the block that checks for requiring a new transaction and timeout.

If you debug "result = methodContext.getDispatcher().runSync(this.serviceName, inMap);" and inspect "this.serviceName" you will get "${serviceName}"
If you inspect "serviceName" you will get "findProjectDetails" which is desired.

To fix my version, I changed the code back to the way "serviceName" used to be:
result = methodContext.getDispatcher().runSync(serviceName, inMap);

Chris Juettner
Integral Business Solutions

Reply | Threaded
Open this post in threaded view
|

Re: CallService throws cannot locate service by name

Adrian Crum
Fixed, rev 610440. Thanks Chris!

-Adrian

Chris Juettner wrote:

> I'm upgrading an old OFBiz based application to the latest Apache version and I discovered a problem with a custom simple method that no longer works.  
> I have traced the problem to the CallService class and a change made last year.  I'm not sure of the protocol to open a Jira Tracker but here's the details.
>
> Simple Method declaration:
>
> <simple-method method-name="getDataMaps" short-description="Call a series of services to assemble a map hierarchy" login-required="false">
>   <iterate-map map-name="parameters.operationMap" key-name="serviceName" value-name="resultMap">
>         <clear-field field-name="serviceMap"/>
>         <set-service-fields service-name="${serviceName}" map-name="parameters" to-map-name="serviceMap"/>
>         <call-service service-name="${serviceName}" in-map-name="serviceMap">
>           <results-to-map map-name="${resultMap}"/>
>         </call-service>
>         <set field="dataMap.${resultMap}" from-field="${resultMap}"/>
> </iterate-map>
>
>
> When this simple method executes it fails (partial debug log)
> 2008-01-08 15:40:41,000 (http-0.0.0.0-8443-Processor4) [Log.java:94 :INFO ] *****getDataMaps parameters.operationMap [findProjectDetails=projectDetails, findCustomAttachment=customAttachment]
> 2008-01-08 15:40:41,000 (http-0.0.0.0-8443-Processor4) [Log.java:94 :INFO ] *****calling service findProjectDetails
> 2008-01-08 15:40:44,500 (http-0.0.0.0-8443-Processor4) [CallService.java:242:ERROR]
> ---- exception report ----------------------------------------------------------
> Exception: org.ofbiz.service.GenericServiceException
> Message: Cannot locate service by name (${serviceName})
> ---- stack trace ---------------------------------------------------------------
> org.ofbiz.service.GenericServiceException: Cannot locate service by name (${serviceName})
> org.ofbiz.service.DispatchContext.getModelService(DispatchContext.java:190)
> org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:143)
> org.ofbiz.minilang.method.callops.CallService.exec(CallService.java:239)
> org.ofbiz.minilang.SimpleMethod.runSubOps(SimpleMethod.java:931)
>
>
> The change is in CallService method exec(MethodContext methodContext) in the block that checks for requiring a new transaction and timeout.
>
> If you debug "result = methodContext.getDispatcher().runSync(this.serviceName, inMap);" and inspect "this.serviceName" you will get "${serviceName}"
> If you inspect "serviceName" you will get "findProjectDetails" which is desired.
>
> To fix my version, I changed the code back to the way "serviceName" used to be:
> result = methodContext.getDispatcher().runSync(serviceName, inMap);
>
> Chris Juettner
> Integral Business Solutions
>
>