Search code examples
spring-xdgemfire

Method call: Method toObject(java.util.LinkedHashMap) cannot be found on org.springframework.integration.x.gemfire.JsonStringToObjectTransformer


I am facing the following issue in Spring XD and gemfire

nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1004E:(pos 8): Method call: Method toObject(java.util.LinkedHashMap) cannot be found on org.springframework.integration.x.gemfire.JsonStringToObjectTransformer type.

Any idea how to fix this?

Following is how we can replicate this issue:

stream create json_test --definition "trigger --fixedDelay=1 | 
transform --expression='''{node1 : {node2 : {data1:hello, data2: world}}}''' | 
splitter --expression=#jsonPath(payload,'$.node1.node2') | 
log" --deploy`

What we are expecting {data1:hello, data2:world} but we are getting {data1=hello, data2=world} which is causing the issue.

What is the solution for this issue?


Solution

  • The gemfire-json-server sink can only handle incoming String JSON payloads; it looks like you are supplying a LinkedHashMap somehow.

    It probably means you have run it through some JSON to object transformation or conversion.

    EDIT

    The splitter produces a LinkedHashMap - specify an outputType to convert it to JSON...

    xd:>stream create json_test --definition "trigger --fixedDelay=1 | 
    transform --expression='''{node1 : {node2 : {data1:hello, data2: world}}}''' | 
    splitter --expression=#jsonPath(payload,'$.node1.node2') --outputType=application/json |
    log" --deploy
    

    Result...

    2017-06-14T09:52:10-0400 1.3.1.RELEASE INFO task-scheduler-2 sink.json_test - {"data1":"hello","data2":"world"}
    2017-06-14T09:52:11-0400 1.3.1.RELEASE INFO task-scheduler-2 sink.json_test - {"data1":"hello","data2":"world"}
    2017-06-14T09:52:12-0400 1.3.1.RELEASE INFO task-scheduler-2 sink.json_test - {"data1":"hello","data2":"world"}