ENGINE-16004 Exception while closing command context: Cannot serialize object in variable 'claimObject': SPIN/DOM-XML-01030 Cannot create context

I am getting an intermittent issue related to Spin while adding a Java object into the process.

    delegateExecution.setVariable("claimObject", claim);

Error:

ENGINE-16004 Exception while closing command context: Cannot serialize object in variable ‘claimObject’: SPIN/DOM-XML-01030 Cannot create context

org.camunda.bpm.engine.ProcessEngineException: Cannot serialize object in variable ‘claimObject’: SPIN/DOM-XML-01030 Cannot create context

I have the following dependencies in POM.xml.

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

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

<dependency>
  <groupId>org.camunda.spin</groupId>
  <artifactId>camunda-spin-dataformat-xml-dom</artifactId>
</dependency>

<dependency>
  <groupId>org.camunda.bpm</groupId>
  <artifactId>camunda-engine-plugin-spin</artifactId>
</dependency>

Please help to resolve this issue.

Note: Getting this issue in Camunda 7.20. It was working fine with Camunda 7.19.