@VariableAsType gives error - io.camunda.zeebe.client.api.command.InternalClientException: Failed to deserialize json

When I use @VariableAsType ProcessVariable in my worker method it gives error -io.camunda.zeebe.client.api.command.InternalClientException: Failed to deserialize json ‘{“result”:false,“businessKey”:“123S4567”,“mapParams”:{}}’ to class ‘class com.evernorth.platforms.fill.scheduling.camunda.model.ProcessVariables’

@VariablesAsType ProcessVariables variables, @CustomHeaders Map header, ActivatedJob job) {
LOG.info("Invoking myService with variables: " + variables);

Where ProcessVariables class is as below :

@Data
public final class ProcessVariables implements Serializable {
private static final long serialVersionUID = 1L;
private String businessKey;
private boolean result;
@NotNull
private final Map<String, Object> mapParams;

Is this related to the following issue here: Problems mixing @Variable and @VariablesAsType parameters in same signature · Issue #421 · camunda-community-hub/spring-zeebe · GitHub?

yeah Thanks @Philipp_Ossler . I used ActivatedJob.VariableasMap and works fine for me.

@ShilpaN.Chalke
For more info,

@VariableAsType intakes all the process variables and tries to map it to a class that we have defined. So, it expects an exact match.

For example, if we have defined a class like

class Foo{
private String var1;
private String var2;
}

And we are having process variables coming in to the job worker from the bpm process instance via the ActivatedJob like

{ 
    "var1" : "Tom",
    "var2" : "Dick",
    "var3" : "Harry"
}

Here, var3 is a bpm process variable that doesn’t match with the instance variables of Foo.class, and the Zeebe Client is not able to handle this extra variable and will throw this error.

1 Like

Thanks @Hariharan_B