Convert getVariables Output to String on WildFly Does Not Work

I want to take the output of the execution.getVariables() method and create a string representation of all process variables. I am using Camunda 7.6.2-ee running in WildFly 10. The output works for variables types like string and integer, but for JSON objects, it only outputs a plain object.

If I simply print the output of execution.getVariables(), I can see the JSON object value, however when using the following code, it only provides a plain object:

ObjectMapper mapper = new ObjectMapper();

String processVariables = mapper.writeValueAsString(execution.getVariables());

This would produce a string like the snippet shown below:

	"timeStamp": "20170621120017",
	"rawMessage": {
		"null": false,
		"array": false,
		"value": false,
		"number": false,
		"object": true,
		"string": false,
		"boolean": false,
		"nodeType": "OBJECT",
		"dataFormatName": "application/json"
	"sourceHost": "O119322F",

The value of “rawMessage” isn’t included, but all others are.

We have determined that we need to use Camunda’s version of ObjectMapper and have attempted to include the org.camunda.spin.camunda-spin-dataformat-all dependency in our project. However, when executed on a WildFly server, we get class not found errors consistently. We have placed this dependency in the POM file manifest and have set the dependency scope to compile so that it is included in the war file.

When I attempt to deploy it, WildFly throws the exception below. Any ideas on how we might fix this?

2017-06-28 08:53:12,375 INFO  [org.camunda.spin] (MSC service thread 1-7) SPIN-01010 Discovered Spin data format provider: org.camunda.spin.impl.json.jackson.format.JacksonJsonDataFormatProvider[name = application/json]
2017-06-28 08:53:12,381 ERROR [] (MSC service thread 1-7) MSC000001: Failed to start service org.camunda.bpm.platform.process-application-module."deployment.Process_PrintCounter1-0.0.4-SNAPSHOT.war:main".START: org.jboss.msc.service.StartException in service org.camunda.bpm.platform.process-application-module."deployment.Process_PrintCounter1-0.0.4-SNAPSHOT.war:main".START: Failed to start service
	at org.jboss.msc.service.ServiceControllerImpl$
	at java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.util.concurrent.ThreadPoolExecutor$
Caused by: java.lang.ExceptionInInitializerError
	at org.camunda.spin.impl.json.jackson.format.JacksonJsonDataFormat.<clinit>(
	at org.camunda.spin.impl.json.jackson.format.JacksonJsonDataFormatProvider.createInstance(
	at org.camunda.spin.DataFormats.registerProvider(
	at org.camunda.spin.DataFormats.registerCustomDataFormats(
	at org.camunda.spin.DataFormats.registerDataFormats(
	at org.camunda.spin.plugin.impl.SpinBpmPlatformPlugin.lookupSpinSerializers(
	at org.camunda.spin.plugin.impl.SpinBpmPlatformPlugin.initializeVariableSerializers(
	at org.camunda.spin.plugin.impl.SpinBpmPlatformPlugin.postProcessApplicationDeploy(
	at org.camunda.bpm.container.impl.jboss.service.ProcessApplicationStartService.notifyBpmPlatformPlugins(
	at org.camunda.bpm.container.impl.jboss.service.ProcessApplicationStartService.start(
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(
	at org.jboss.msc.service.ServiceControllerImpl$
	... 3 more
Caused by: java.lang.ClassCastException: org.camunda.spin.impl.json.jackson.JacksonJsonLogger cannot be cast to org.camunda.commons.logging.BaseLogger
	at org.camunda.commons.logging.BaseLogger.createLogger(
	at org.camunda.spin.impl.json.jackson.JacksonJsonLogger.<clinit>(
	... 15 more

2017-06-28 08:53:12,847 ERROR [] (management-handler-thread - 16) WFLYCTL0013: Operation ("full-replace-deployment") failed - address: ([]) - failure description: {
    "WFLYCTL0080: Failed services" => {"org.camunda.bpm.platform.process-application-module.\"deployment.Process_PrintCounter1-0.0.4-SNAPSHOT.war:main\".START" => "org.jboss.msc.service.StartException in service org.camunda.bpm.platform.process-application-module.\"deployment.Process_PrintCounter1-0.0.4-SNAPSHOT.war:main\".START: Failed to start service
    Caused by: java.lang.ExceptionInInitializerError
    Caused by: java.lang.ClassCastException: org.camunda.spin.impl.json.jackson.JacksonJsonLogger cannot be cast to org.camunda.commons.logging.BaseLogger"},
    "WFLYCTL0412: Required services that are not installed:" => ["org.camunda.bpm.platform.process-application-module.\"deployment.Process_PrintCounter1-0.0.4-SNAPSHOT.war:main\".START"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
2017-06-28 08:53:12,848 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 99) WFLYUT0022: Unregistered web context: /Process_PrintCounter1-0.0.4-SNAPSHOT
2017-06-28 08:53:12,850 INFO  [] (MSC service thread 1-7) WFLYJCA0019: Stopped Driver service with driver-name = Process_PrintCounter1-0.0.4-SNAPSHOT.war_com.mysql.jdbc.Driver_5_1
2017-06-28 08:53:12,850 INFO  [] (MSC service thread 1-4) WFLYJCA0019: Stopped Driver service with driver-name = Process_PrintCounter1-0.0.4-SNAPSHOT.war_com.mysql.fabric.jdbc.FabricMySQLDriver_5_1
2017-06-28 08:53:13,505 INFO  [] (MSC service thread 1-5) WFLYSRV0028: Stopped deployment Process_PrintCounter1-0.0.4-SNAPSHOT.war (runtime-name: Process_PrintCounter1-0.0.4-SNAPSHOT.war) in 656ms
2017-06-28 08:53:13,505 ERROR [] (management-handler-thread - 16) WFLYCTL0190: Step handler$4@3c76020d for operation {"operation" => "full-replace-deployment","address" => [],"name" => "Process_PrintCounter1-0.0.4-SNAPSHOT.war","content" => [{"input-stream-index" => 0}],"enabled" => true,"operation-headers" => {"caller-type" => "user","access-mechanism" => "NATIVE"},"runtime-name" => undefined,"persistent" => true,"owner" => undefined} at address [] failed handling operation rollback -- java.util.NoSuchElementException: No child 'name' exists: java.util.NoSuchElementException: No child 'name' exists
	at org.jboss.dmr.ModelValue.requireChild(
	at org.jboss.dmr.ObjectModelValue.requireChild(
	at org.jboss.dmr.ModelNode.require(
	at Method)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.util.concurrent.ThreadPoolExecutor$

Hi Michael,

For object type variables, would it be sufficient to display the serialized value? In your example, you ask the process engine to deserialize the variables (via execution#getVariables) only then to use Jackson to serialize them again to JSON. If all your object variables are serialized in a human-readable format, then you could directly use the serialized String value that can be accessed via execution#getVariablesTyped etc. In that case, you don’t need to use Jackson and things should get a lot easier.


1 Like

I have to first state my relative ignorance in Java (sorry, I know, I’m pathetic), so I’ll try to answer the question. I think the answer is yes, we can use the serialized values. In most cases, these objects are actually JSON, sometimes JSON wrapped around JSON.

The values output be by the simple execution.getVariables() method are acceptable.

We’re trying a workaround right now to iterate through the map, classify each type, and then use an appropriate statement to craft a JSON entry, but even that is a challenge.

Sounds good to me. If you iterate over the result of execution.getVariablesTyped(), then you can check if a value is an instance of SerializableValue, then cast it to SerializableValue and use SerializableValue#getValueSerialized to access the JSON Camunda stores.

We did the following. The purpose was to put all the process variables into a JSON string.

ObjectMapper mapper = new ObjectMapper();

Iterator<Entry<String, Object>> variablesIterator = execution.getVariables().entrySet().iterator(); 


    String variableName = null;

        Entry<String, Object> variableEntry =; 
        variableName = variableEntry.getKey(); 
        Object variableObject = variableEntry.getValue(); 
            case "String": 
                processVariables += "\"" + variableName + "\":" + mapper.writeValueAsString((String)variableObject); 
            case "Integer": 
                processVariables += "\"" + variableName + "\":" + (Integer)variableObject; 
            case "Boolean": 
                processVariables += "\"" + variableName + "\":" + (Boolean)variableObject; 
            case "JacksonJsonNode": 
                JsonValue jsonValue = execution.getVariableTyped(variableName); 
                processVariables += "\"" + variableName + "\":" + jsonValue.getValueSerialized(); 
            processVariables += "\"" + variableName + "\":" + mapper.writeValueAsString(variableObject); 
            processVariables += ","; 
    catch(Exception exception)