Cannot use the JSON evaluator with ctx in latest EI versions
1 min readJan 28, 2020
- If we evaluate the JSON path as below we will receive the following error.
<arg evaluator="json" expression="$ctx:Error"/>
The error which we can receive
ERROR {org.apache.synapse.deployers.TemplateDeployer} - Template Deployment from the file : C:\wso2\wso2ob-ei-6.4.0\wso2\tmp\carbonapps\-1234\1578920589309test-composite-application_1.0.0.car\test_app_1.0.0\test_app-1.0.0.xml : Failed.
com.jayway.jsonpath.InvalidPathException: Illegal character at position 1 expected '.' or '[
at com.jayway.jsonpath.internal.path.PathCompiler.fail(PathCompiler.java:616)
at com.jayway.jsonpath.internal.path.PathCompiler.readContextToken(PathCompiler.java:120)
at com.jayway.jsonpath.internal.path.PathCompiler.compile(PathCompiler.java:58)
at com.jayway.jsonpath.internal.path.PathCompiler.compile(PathCompiler.java:75)
- JSON path is evaluated from the “com.jayway.jsonpath.json-path_2.2.0” library and this library has been updated with the latest EI versions. After this update, it only supports the JSON dot notation and for the bracket notations
- To overcome this issue you can evaluate the above using the XML as the evaluator.
<arg evaluator="xml" expression="$ctx:Error"/>