Cannot deserialize object in va riable 'testEvent': SPIN/DOM-XML-01009 Unable to parse input into DOM document'

Hi,
When I try to get the variable “testEvent” I am getting below error. I dont find solution.
I want to get the variable and want to convert into my custom TestEvent class.
Could you please help me on this.
@Override
public void notify(DelegateTask task) {
ObjectValue retrievedTypedObjectValue = task.getVariableTyped(“testEvent”);
TestEvent poe = (TestEvent) retrievedTypedObjectValue.getValue();
}

Error:
2022-09-22 19:51:00.744 ERROR 17712 — [nio-8080-exec-4] org.camunda.bpm.engine.context : ENGINE-16004 Exception while closing command contex
t: ENGINE-03051 There was an exception while invoking the TaskListener. Message: ‘Exception while invoking TaskListener: Cannot deserialize object in va
riable ‘testEvent’: SPIN/DOM-XML-01009 Unable to parse input into DOM document’

org.camunda.bpm.engine.ProcessEngineException: ENGINE-03051 There was an exception while invoking the TaskListener. Message: ‘Exception while invoking T
askListener: Cannot deserialize object in variable ‘testEvent’: SPIN/DOM-XML-01009 Unable to parse input into DOM document’
at org.camunda.bpm.engine.impl.db.EnginePersistenceLogger.invokeTaskListenerException(EnginePersistenceLogger.java:451) ~[camunda-engine-7.14.0.
jar!/:7.14.0]

Hi,
Based on your error message, you are using Camunda Spin for the serialization and deserialization of objects, and it’s assuming that the serialization format is XML.

Have you checked the serialized value of the testEvent? Is the XML valid?

Not all objects can be deserialized automatically. You may need to annotate your class (see this page in the documentation). Also check out the documentation on using XML in camunda 7.

Spin is based on FasterXML Jackson corresponding documentation may help you as well.

spin://application/xml - This is the type using to store into database.
Retriving not in the xml format in json format… Annotating my class with “@JsonIgnoreProperties
Same code is working for another task. when it is coming to 2nd task it is not working. 1st task was succeed with the same code.

Hi @StephanHaarmann ,
I am not getting always. I am getting this error randomly. Sometimes it is getting passed successfully. Not able to debug the reason.

That sounds confusing.
Can you log the JSON (i.e., by converting it into a String instead of TestEvent)?
Maybe a comparison of the successful and unsuccessful cases provides gives us some insights.
You can also try to parse the object manually, by using Spins JSON converter.