Jackson - ClassCastException ArrayNode to ArrayNode

I think this may be a known issue due to library differences within Spin.

I’m seeing this odd cast exception:

Caused by: java.lang.ClassCastException: com.fasterxml.jackson.databind.node.ArrayNode cannot be cast to com.fasterxml.jackson.databind.node.ArrayNode

Causing the error

        if(processVariableValue.getClass().getSimpleName().equalsIgnoreCase("JacksonJsonNode")) {
          if( ((Spin)processVariableValue).unwrap().getClass().getSimpleName().equalsIgnoreCase("ArrayNode")) {
            LOGGER.info("*** Found ArrayNode");
            ArrayNode arrayNode = (ArrayNode) ((Spin)processVariableValue).unwrap(); <<< fails here
            processVariablesNode.set("foo", arrayNode);
          }
          //JsonNode jsonNode = (JsonNode) ((Spin)processVariableValue).unwrap();

          //JsonNode jsonNode = mapper.readTree(processVariableValue.toString());
          //processVariablesNode.set(processVariableName.toString(), jsonNode);          
        } else {
          processVariablesNode.put(processVariableName.toString(), processVariableValue.toString());
        }

minor workaround - but wanted to verify

          JsonNode jsonNode = mapper.readTree(processVariableValue.toString());
          processVariablesNode.set(processVariableName.toString(), jsonNode);  

Hi Gary,

You are on Wildfly, correct?

Cheers,
Thorben

Yes - WildFly v10+

With Camel subsystem dropped in via fuse:

        <extension module="org.camunda.bpm.wildfly.camunda-wildfly-subsystem"/>
        <extension module="org.wildfly.extension.camel"/>

In this case, there are two versions of the Jackson classes in the game. Your application depends on a different Jackson module than the Spin module, so the instances of Jackson classes returned by Spin are not compatible with the classes your application loads. Your application needs to depend on the same Jackson module that Spin does. See for Camunda JSON marshalling and @JsonIgnore for a similar discussion and solutions.

Thanks!
Thought I remembered seeing this somewhere.

Is there a pending fix to line up Jackson libraries per platform?

Though there might be some fun in here if we all switched over to OSGi to help resolve this sort of trouble…

Appreciate the detailed solution (above link)

Hm, could you please rephrase your question? :slight_smile:

I’ll take a look at sync’ing up the jackson version in the build.

Camunda’s build infrastructure - assuming it’s as good as the JDBC driver section… shouldn’t take too long.

I need to get some core work done though - something to test locally before porting it all over to a bigger system (I typically run the big builds on a traditional server).

P.S. Camunda’s build/pom configs are very well organized.