Unable to evaluate custom functions

Hi, I am trying to evaluate a custom function in a DRD.
I have registered the function into SpringProcessEngineConfiguration as “configuration.setExpressionManager(expressionManager);”
I am able to evaulate the DRD with custom function from camunda rest api (…/rest/decision-definition/key//evaluate ), but I am not able to evaluate the custom functions from Java program using
DmnDecisionResult result= getDmnEngine().evaluateDecision(decision, contextMap);
Error message is
{
“status”: 400,
“message”: “error”,
“result”: “DMN-01002 Unable to evaluate expression for language ‘juel’: ‘${customlib:gRandomNumber() + 1.0}’”
}

When I try to debug the code, I could see the error stating “org.camunda.bpm.engine.ProcessEngineException: Expression can only be evaluated inside the context of the process engine” at evaluateElExpression.

Can you please suggest what is the issue here.

Thanks