Cannot be cast to org.camunda.spin.plugin.variable.value.JsonValue

Process Started with the following Input as Json.


Java Delegate

import org.camunda.spin.plugin.variable.value.JsonValue;
import org.camunda.spin.plugin.variable.value.impl.JsonValueImpl;
import org.camunda.spin.impl.json.jackson.JacksonJsonNode;
import static org.camunda.spin.Spin.*;

public class GetDetailsDelegate implements JavaDelegate {
	public void execute(DelegateExecution execution) throws Exception {
		JsonValue customer2 = execution.getVariableTyped("customerData");*


When I am printing customer details as jsonvalue, I am getting following error.

java.lang.ClassCastException: org.camunda.spin.plugin.variable.value.impl.JsonValueImpl cannot be cast to org.camunda.spin.plugin.variable.value.JsonValue

Hi @somehanu,

can you please provide more information about your environment and the Camunda version.
Do you use a shared process engine?
What application server do you use?
Can you provide a failing test?

Maybe, it’s a problem with the class loading. Please check that library is loaded only once.

Best regards,

Issue get solved by using the spin fasterxml object mapper as following. Because camunda treating json request as object

Imported Libraries;


Example Code:

Object customer = execution.getVariableTyped("customerData").getValue(); 
String customerValues = customer.toString();
ObjectMapper mapper = new ObjectMapper();
LoanDetail customers = mapper.readValue(customerValues, CustomerData.class);
1 Like

I preffer add aditional rest endpoint.
You need add 2 files to project:

  1. JerseyConfig -
    public class JerseyConfig extends CamundaJerseyResourceConfig {

    protected void registerAdditionalResources() {

  2. TaskFieldsService:

public class TaskFieldsService {

public String getFormFieldList(@Context HttpHeaders httpHeaders, @PathParam("taskId") String taskId ){

        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        FormService formService = processEngine.getFormService();
        TaskFormData taskFormData = formService.getTaskFormData(taskId);
        List<FormField> formFieldList = taskFormData.getFormFields();
        String json = JSON(formFieldList).toString();
        return json;



So you can get form atributes by GET /taskfields/905