Spin ClassCastException

As we evaluate the Camunda product line for use in workflow, I’ve written a simple application to demonstrate to our infrastructure group. I’ve been able to build it and run it with an embedded engine as a Spring Boot application, but have been having problems running it with a shared engine (we are evaluating both options).

I am seeing the following error:

java.lang.ClassCastException: com.ncs.domain.BaseDomain$JaxbAccessorM_getId_setId_java_lang_String cannot be cast to spinjar.com.sun.xml.bind.v2.runtime.reflect.Accessor

In my Spring Boot application I do not use camunda-spin-dataformat-all; I use the two individual (json and xml) jars and it works fine. With the Camunda Tomcat distribution, I don’t see that as an option without making changes to the installation.

I am using a Spring REST controller to start a process instance by message. I set the process application context beforehand. All Camunda dependencies (version 7.12.0) are declared as provided in the pom. The “WorkflowRequest” object is defined in an external library over which I have very little control. The error occurs when I invoke startProcessInstanceByMessage. Any suggestions on how to work around this would be most appreciated.

Controller code:

package com.ncs.demo.workflow.multiinstance.thirteencell.web.controller;

import org.camunda.bpm.application.ProcessApplicationContext;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.camunda.bpm.engine.variable.Variables;
import org.camunda.bpm.engine.variable.value.ObjectValue;
import org.camunda.spin.DataFormats;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.ncs.domain.enterprise.esb.workflow.request.WorkflowRequest;

@RestController
@RequestMapping(value = "/workflow")
public class MessageController {
	private static Logger log = LoggerFactory.getLogger(MessageController.class);

	@Autowired
	private RuntimeService runtimeService;

	@RequestMapping(value = "/{messageName}/**", method = RequestMethod.POST, consumes = MediaType.APPLICATION_XML_VALUE)
	public void processRequest(@PathVariable("messageName") String messageName, @RequestBody WorkflowRequest request) {
		log.debug("Sending message to " + messageName);
		log.debug("Request id = " + request.getId());

		try {
			ProcessApplicationContext.setCurrentProcessApplication("workflow");
			ObjectValue objectValue = Variables.objectValue(request).serializationDataFormat(DataFormats.XML_DATAFORMAT_NAME).create();
			ProcessInstance processInstance = runtimeService.startProcessInstanceByMessage(messageName, request.getId(), Variables.putValue("workflowRequest", objectValue));
			//ProcessInstance processInstance = runtimeService.startProcessInstanceByMessage(messageName, request.getId(), Variables.putValue("workflowRequest", request));

			log.debug("Started processInstance " + processInstance.getProcessInstanceId());
		} finally {
			ProcessApplicationContext.clear();
		}
	}
}

No takers yet on this one, so please let me know if you need more information to address my question.

Right now I have replaced camunda-spin-dataformat-all-1.7.4.jar in the server’s lib directory with the following individual spin jars and their dependencies:

accessors-smart-1.2.jar
camunda-spin-dataformat-json-jackson-1.7.4.jar
camunda-spin-dataformat-xml-dom-1.7.4.jar
jackson-annotations-2.10.0.jar
jackson-core-2.10.0.jar
jackson-databind-2.10.0.jar
json-path-2.4.0.jar
json-smart-2.3.jar

This resolves the ClassCastException, and my XML request is successfully parsed and the message received. However, I would like a solution that does not require modification to the default Camunda Tomcat installation. Is there some way, perhaps through SPI, that I can specify the parser that I want to use at runtime while using camunda-spin-using dataformat-all?

Thank you.

Is there anyone there at Camunda who works with Spin who can answer this question? Thanks.