Call activities and ClassCastExceptions when mapping variables

Hi all,

let’s assume we have two process applications deployed as two war-files on a jboss server.

The parent process has a call activity to start the subprocess. But we want to hand over some (structured) data to the subprocess, so we implement the DelegateVariableMapping interface and add an object of type “Person” (just as an example). The domain class “Person” is located in a common jar file which both applications have in the compile scope (as maven dependency).

The subprocess has a service task where this variable is read. Here we will get a ClassCastException because the “Person” class of the variable instance handed over by the parent process is loaded by a different class loader as the “Person” class of the subprocess. Hence the clash…

Well, the most obious approach is to serialize the variable and hand it over as JSON/XML.
This can be done manually but then we need a deserialize-task/listener at the beginning of the subprocess. But maybe this subprocess is also started via a webservice interface. In this case, we would not get a JSON string but the ready to use java object…

We can also insert some wait-state (asyncBefore=true) before the variable is read for the first time - then the persistence layer of the engine will serialize the object, write it to the DB, read it from the DB and deserialize it with the class of the subprocess. This would fix the exception but maybe we need a synchronous feedback of the subprocess and cannot add this wait state…

So I am looking for a platform-wide solution to not have to deal with this problem in each process application. Any suggestions?

Thanks!
Sebastian

Hi Sebastian,

what about making a JBoss module out of the shared jar and letting both applications depend on it?

Cheers,
Thorben

Any idea how this kind of exception can be caused in a single Spring Boot app? Putting a save point, i.e. asyncBefore=true, between setting the variable and reading it seems to help.

HI @falko.menge,

Do you start the app from the IDE? Then you get tricky class loader magic from the spring boot devtools.

If you start with mvn clean package and java -jar it should be fine.

Hope this helps, Ingo

Yes we were using Spring Dev Tools and it seems to work without it. Thank you for the hint! That also explains why in one situation it helped to switch from delegate expression to Java class as invocation method.