Exception in storing serialized Java Custom Objects

I was trying to store the below serialized custom java object using camunda Rest api( POST /process-definition/key/{key}/tenant-id/{tenant-id}/start) requestBody (processvariables):

{
  "variables": {
    "serviceAuthToken": {
      "value": "{\"apiKey\":\"key1\",\"token\":\"token\",\"currentTenant\":\"tenant1\",\"userId\":\"userId\"}",
      "type": "Object",
      "valueInfo": {
        "objectTypeName": "com.camunda.dto.ServiceAuthToken",
        "serializationDataFormat": "application/json"
      }
    }
  }
}

Java Class:

@Getter
@Setter
@NoArgsConstructor
public class ServiceAuthToken implements Serializable {

  private static final long serialVersionUID = 1L;

  private String apiKey;
  private String token;
  private String currentTenant;
  private String userId;
}

Exception:

[org.camunda.bpm.engine.context] [logError] @ 156 : ENGINE-16004 Exception while closing command context: Cannot find serializer for value 'ObjectValue [value=null, isDeserialized=false, serializationDataFormat=application/json, objectTypeName=com.camunda.dto.ServiceAuthToken, serializedValue=827 chars, isTransient=false]'. 
org.camunda.bpm.engine.ProcessEngineException: Cannot find serializer for value 'ObjectValue [value=null, isDeserialized=false, serializationDataFormat=application/json, objectTypeName=com.camunda.dto.ServiceAuthToken, serializedValue=827 chars, isTransient=false]'.
	at org.camunda.bpm.engine.impl.variable.serializer.DefaultVariableSerializers.findSerializerForValue(DefaultVariableSerializers.java:84)
	at org.camunda.bpm.engine.impl.persistence.entity.util.TypedValueField.setValue(TypedValueField.java:110)
	at org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity.<init>(VariableInstanceEntity.java:122)
	at org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity.create(VariableInstanceEntity.java:141)
	at org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntityFactory.build(VariableInstanceEntityFactory.java:27)

Any suggestions to solve this problem?

Hi

Do you have solve your problem ? I have same

Regards

@pcouas my payload was wrong, later I fixed it

Ok i have fixed problem dependency are missing in BPM example

    <dependency>
    <groupId>org.camunda.spin</groupId>
    <artifactId>camunda-spin-dataformat-json-jackson</artifactId>
    <version>1.8.0</version>
</dependency>

<dependency>
    <groupId>org.camunda.spin</groupId>
    <artifactId>camunda-spin-core</artifactId>
    <version>1.8.0</version>
</dependency>

Can you clarify what was wrong in your payload and what the correct payload is?

Also, could you provide more detail on if you are using Jackson’s ObjectMapper(), Camunda SPIN, JSONObject() or any other method to convert your custom Java object to JSON please.