ExternalTaskClient possible bug with Spin and XML provenance

Hey,

after experimenting with the External Task Engine for a while I noticed that
org.camunda.spin:camunda-spin-core and org.camunda.spin:camunda-spin-dataformat-all, both with provided jars with version 7.12.0, behave not as documented when used with external tasks that add process variables on completion.

Case Study 1:

The following object combinedXML should be persisted after completing my external task. CombinedXML was created with SpinValues.xmlValue(XML(reader)).create() where reader is a reader to the provided XML file. Note that neither public static XmlValueBuilder xmlValue(org.camunda.spin.xml.SpinXmlElement value) nor create() are documented, I just went along with your tutorial here XML | docs.camunda.org. The object is then added to a hashmap that is used in the completion call org.camunda.bpm.client.task.ExternalTaskService void complete(ExternalTask externalTask, Map <String ,Object > variables).

This results in the following exception:

Caused by: org.camunda.bpm.client.exception.ValueMapperException: TASK/CLIENT-01023 Cannot find serializer for value 'Value '<?xml version="1.0" encoding="UTF-8"?><rdf:RDF xmlns:[...]
' of type 'xml', isTransient=false'
		at org.camunda.bpm.client.impl.ExternalTaskClientLogger.valueMapperExceptionDueToSerializerNotFoundForTypedValue(ExternalTaskClientLogger.java:189)
		at org.camunda.bpm.client.variable.impl.DefaultValueMappers.findMapperForTypedValue(DefaultValueMappers.java:70)
		at org.camunda.bpm.client.variable.impl.TypedValues.findSerializer(TypedValues.java:114)
		at org.camunda.bpm.client.variable.impl.TypedValues.toTypedValueField(TypedValues.java:92)
		at org.camunda.bpm.client.variable.impl.TypedValues.serializeVariables(TypedValues.java:56)
		... 11 more

Case Study 2:

The following XmlValue was created with your example XML snippet from XML | docs.camunda.org.

This results in

org.camunda.bpm.client.exception.ValueMapperException: TASK/CLIENT-01025 Cannot serialize variable 'combinedXML'
		at org.camunda.bpm.client.impl.ExternalTaskClientLogger.cannotSerializeVariable(ExternalTaskClientLogger.java:199)
		at org.camunda.bpm.client.variable.impl.TypedValues.serializeVariables(TypedValues.java:60)
		at org.camunda.bpm.client.impl.EngineClient.complete(EngineClient.java:89)
		at org.camunda.bpm.client.task.impl.ExternalTaskServiceImpl.complete(ExternalTaskServiceImpl.java:62)
		at org.camunda.bpm.client.task.impl.ExternalTaskServiceImpl.complete(ExternalTaskServiceImpl.java:56)
		at  [...]
at org.camunda.bpm.client.topic.impl.TopicSubscriptionManager.handleExternalTask(TopicSubscriptionManager.java:152)
		at org.camunda.bpm.client.topic.impl.TopicSubscriptionManager.lambda$acquire$0(TopicSubscriptionManager.java:108)
		at java.base/java.util.Arrays$ArrayList.forEach(Arrays.java:4411)
		at org.camunda.bpm.client.topic.impl.TopicSubscriptionManager.acquire(TopicSubscriptionManager.java:103)
		at org.camunda.bpm.client.topic.impl.TopicSubscriptionManager.run(TopicSubscriptionManager.java:87)
		at java.base/java.lang.Thread.run(Thread.java:830)
	Caused by: org.camunda.bpm.client.exception.ValueMapperException: TASK/CLIENT-01023 Cannot find serializer for value 'Value 'null' of type 'xml', isTransient=false'
		at org.camunda.bpm.client.impl.ExternalTaskClientLogger.valueMapperExceptionDueToSerializerNotFoundForTypedValue(ExternalTaskClientLogger.java:189)
		at org.camunda.bpm.client.variable.impl.DefaultValueMappers.findMapperForTypedValue(DefaultValueMappers.java:70)
		at org.camunda.bpm.client.variable.impl.TypedValues.findSerializer(TypedValues.java:114)
		at org.camunda.bpm.client.variable.impl.TypedValues.toTypedValueField(TypedValues.java:92)
		at org.camunda.bpm.client.variable.impl.TypedValues.serializeVariables(TypedValues.java:56)
		... 11 more

Which can actually be sort of explained when looking at the generated XmlValue object that is missing it’s value property when generated from a string via SpinValues.xmlValue(String myString).create()

Spin is properly integrated in my server as documented in Install the Full Distribution on a Tomcat Application Server manually | docs.camunda.org.

Hey @Einstein,

at a first glance, I’d say Spin is not properly integrated in your ExternalTask Client.
It might be well setup for the server, but the error logs seem to come from the client, not the server.
Am I missing something here?

Best,
Tobias

Hey Tobias,

for integrating the ExternalTaskClient I followed this guide: GitHub - camunda/camunda-external-task-client-java: This codebase was merged with https://github.com/camunda/camunda-bpm-platform. Only some maintenance branches might still be active.. The only thing I changed were some exclusions because my Server already provided jars that were used by the client:

<dependency>
      <groupId>org.camunda.bpm</groupId>
      <artifactId>camunda-external-task-client</artifactId>
      <version>1.3.0</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.camunda.commons</groupId>
          <artifactId>camunda-commons-typed-values</artifactId>
        </exclusion>
      </exclusions>
</dependency>

I’m guessing the TypedValues artifact changed some classes that made it incompatible with newer versions.

Also looking at the screenshot below I think it’s a versioning issues of various classes that couldn’t be mapped to each other, since there obviously is an XmlValueMapper and the data type is “xml”.

I’ll try going with another version and then report back to you.

Best regards

Okay, so the version was the correct one and the provided jar also supplies the right version.

I was able to zero in on the actual line that caused the state to get faulty. In the figure below you can see that the mapper does a class type check on both AbstractValueTypes but the one that was generated with SpinValues.xmlValue(XML(reader)).create(); produces a typed value of type XmlValueTypeImpl derived from SpinValueTypeImpl while the mapper holds a type implementation from PrimitiveValueTypeImpl.

(Taken from org.camunda.bpm.client.variable.impl.AbstractTypedValueMapper)

Type from DefaultValueMappers in org.camunda.bpm.client.variable.impl

grafik

Type generated from SpinValues.xmlValue(XML(reader)).create();

grafik

Hey, since I’m pretty sure that this is a bug with the Spin Framework at this point I’d love to hear a response from you guys.

Usually the forum isn’t used to report bugs, but just discuss issues around camunda.
If you think it’s a bug please feel free to create a ticket : https://jira.camunda.com/
The Dev team will then be able to consider it and track it.

Alright, thank you for the quick response. I’ll submit the issue on Jira.