Error - Cannot find serialize for value 'ObjectValue from jUnit

Hello All,

Env:- Camunda Spring boot 7.13

I have the below code in java delegate called from the “service task”. The work flow runs fine when invoked but the javadelagate gives the "org.camunda.bpm.engine.ProcessEngineException: Cannot find serializer for value 'ObjectValue" when it gets invoked from the Junit .

image

 @Component("GetItemData")
 public class GetItemData implements JavaDelegate {

	@Override
	public void execute(DelegateExecution execution) throws Exception {
		String itemsList = "{\n" +
				"  \"firstName\": \"John\",\n" +
				"  \"lastName\" : \"doe\",\n" +
				"  \"age\"      : \"26\",\n" +
				"  \"items\": [\n" +
				"    {\n" +
				"      \"value\"  : \"iPhone\",\n" +
				"      \"category\": \"mobile\"\n" +
				"    },\n" +
				"    {\n" +
				"      \"value\"  : \"Pixel\",\n" +
				"      \"number\": \"mobile\"\n" +
				"    }\n" +
				"  ]\n" +
				"}";
		Spin itemDataJSON = JSON(itemsList);
		TypedValue typedTransientObjectValue = Variables.objectValue(itemDataJSON, true).serializationDataFormat(Variables.SerializationDataFormats.JSON).create();
		execution.setVariable("itemsData", typedTransientObjectValue);
	}
}

Test Code

@Test
@Deployment(resources = {"SampleFlow.bpmn", "process1"})
public void createSampleFlow() throws Exception {
    Mocks.register("GetItemData", new GetItemData());
    RuntimeService runtimeService = engine.getRuntimeService();
    HistoryService historyService = engine.getHistoryService();
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("SampleFlow", "ORDER-01");
    List<HistoricProcessInstance> processInstancesList = historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKey("ORDER-01").list();
    assertEquals(processInstancesList.size(), 3);

}

When this code is run below is the exception i see

   org.camunda.bpm.engine.ProcessEngineException: Cannot find serializer for value 'ObjectValue [value={"firstName": "John","lastName" : "doe","age": "26","items": [{"value"  : "iPhone","category": "mobile"},{"value"  : "Pixel","number": "mobile"}] }, isDeserialized=true, serializationDataFormat=application/json, objectTypeName=null, serializedValue=null, isTransient=true]'.
	at org.camunda.bpm.engine.impl.variable.serializer.DefaultVariableSerializers.findSerializerForValue(DefaultVariableSerializers.java:88)
	at org.camunda.bpm.engine.impl.persistence.entity.util.TypedValueField.setValue(TypedValueField.java:122)
	at org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity.<init>(VariableInstanceEntity.java:129)
	at org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity.create(VariableInstanceEntity.java:148)
	at org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntityFactory.build(VariableInstanceEntityFactory.java:31)

POM :-

       <properties>
    <camunda.spring-boot.version>7.13.0</camunda.spring-boot.version>
    <spring-boot.version>2.2.5.RELEASE</spring-boot.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>${spring-boot.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>

    <dependency>
        <groupId>org.camunda.bpm.springboot</groupId>
        <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
        <version>${camunda.spring-boot.version}</version>
    </dependency>

    <dependency>
        <groupId>org.camunda.bpm</groupId>
        <artifactId>camunda-engine-plugin-spin</artifactId>
        <version>${camunda.spring-boot.version}</version>
    </dependency>

    <dependency>
        <groupId>org.camunda.spin</groupId>
        <artifactId>camunda-spin-dataformat-all</artifactId>
        <version>1.9.0</version>
    </dependency>

    <dependency>
        <groupId>org.camunda.bpm.springboot</groupId>
        <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
        <version>${camunda.spring-boot.version}</version>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>


    <dependency>
        <groupId>org.camunda.bpm.assert</groupId>
        <artifactId>camunda-bpm-assert</artifactId>
        <version>7.0.0</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.camunda.bpm.springboot</groupId>
        <artifactId>camunda-bpm-spring-boot-starter-test</artifactId>
        <version>7.13.0</version>
        <!--			<type>jar.sha256</type>-->
        <scope>test</scope>
    </dependency>

Hello All ,

Any inputs or suggestions on how to resolve this .

Thanks
Dinesh

When you use spin/json you manually have to register the spin-plugin on your in memory process engine …