VKP
VKP

Reputation: 658

Cannot coerce array to object while Invoking Java method in Mule

I am trying to pass entire payload to my java class . This is my payload .

[
 {
    "op": "replace",
    "path": "baseLoanAmount",
    "value": "10000.00"
 }
]

This is my java class

public void test(Object payload) {
    System.out.println("Inside Test  ******** "+payload);
}

In invoke i am calling the method like test(Object) and passing payload as argument. But i am getting an error saying Cannot coerce array to object . How i can pass it ?

enter image description here

Upvotes: 0

Views: 723

Answers (1)

aled
aled

Reputation: 25837

The error makes sense, because the parameter is an Object and the argument is an array. Try making the parameter an array, for example test(Object[] payload).

Upvotes: 1

Related Questions