JSON Object serialization failed

4,494 views
Skip to first unread message

Ingo Richtsmeier

unread,
Dec 9, 2014, 10:56:49 PM12/9/14
to camunda-...@googlegroups.com
Hi,

I try to save my result from the business rules task as a JSON object, but it fails with this exception:

org.camunda.bpm.engine.ProcessEngineException: Cannot find serializer for value 'Untyped value 'DroolsCountry(name=Nigeria, hint=counterparty is in a high risk country, highRisk=true)''.
at org.camunda.bpm.engine.impl.variable.serializer.DefaultVariableSerializers.findSerializerForValue(DefaultVariableSerializers.java:69)
at org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity.setValue(VariableInstanceEntity.java:264)

This is the most important code from my delegate class:

Class<?> clazz = Class.forName(factClassName);
Object country = clazz.newInstance();
Field setName = clazz.getDeclaredField("name");
setName.setAccessible(true);
setName.set(country, countryName);
// DroolsCountry droolsCountry = new DroolsCountry();
// droolsCountry.setName((String) countryName);
StatefulKnowledgeSession workingMemory = createWorkingMemory(decisionTablePath);
workingMemory.insert(country);
// workingMemory.insert(droolsCountry);
int numberOfRules = workingMemory.fireAllRules();
log.info("Number of Rules fired from the decisionTable " + decisionTablePath + ": " + numberOfRules);
// ObjectValue typedDroolsCountry =
//  Variables.objectValue(country)
//  .serializationDataFormat("application/json")
//  .create();
// log.info("object type name: " + typedDroolsCountry.getObjectTypeName());

// execution.setVariable("droolsCountry", typedDroolsCountry);
// execution.setVariable("droolsCountry", droolsCountry);
execution.setVariable("droolsCountry", country);

I even played around with typed Objects without reflection, but I get the same exception.

The default serialization format is set in process engine plugin:

log.info("set default serialzation to JSON");
processEngineConfiguration.setDefaultSerializationFormat("application/json");
log.info("default serialization format now " + processEngineConfiguration.getDefaultSerializationFormat());

What is missing?

Regards, Ingo

Melissa Palmer

unread,
Dec 10, 2014, 2:02:53 AM12/10/14
to camunda-...@googlegroups.com
Hi Ingo 

Did you try including Camunda Spin? 

See http://docs.camunda.org/latest/guides/user-guide/#process-engine-process-variables search for "Object Value Serialization" you'll see the following info: 
Serializing Objects to XML and JSON:

The camunda Spin plugin provides serializers that are capable of serializing object values to XML and JSON. They can be used when it is desired that the serialized objects values can be interpreted by humans or when the serialized value should be meaningful without having the corresponding Java class.

When using a pre-built camunda distribution, camunda Spin is already preconfigured and you can try these formats without further configuration.

You might need to go through the steps at: http://docs.camunda.org/latest/guides/user-guide/#data-formats-xml-json-other-configuring-spin-integration 

Cheers
Melissa

Ingo Richtsmeier

unread,
Dec 10, 2014, 3:14:27 AM12/10/14
to camunda-...@googlegroups.com

Hi Melissa,

 

Yes, my pom.xml has the dependencies for spin.

 

   

       <dependency>

             <groupId>org.camunda.spin</groupId>

             <artifactId>camunda-spin-core</artifactId>

             <version>1.0.1</version>

             <scope>provided</scope>

       </dependency>

       <dependency>

             <groupId>org.camunda.spin</groupId>

             <artifactId>camunda-spin-dataformat-json-jackson</artifactId>

             <version>1.0.1</version>

             <scope>provided</scope>

       </dependency>

       <dependency>

             <groupId>org.camunda.bpm</groupId>

             <artifactId>camunda-engine-plugin-spin</artifactId>

             <version>${camunda.version}</version>

             <scope>provided</scope>

       </dependency>

      

Any special library missing?

 

Regards, Ingo

 

 

--
You received this message because you are subscribed to the Google Groups "camunda BPM users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camunda-bpm-us...@googlegroups.com.
To post to this group, send email to camunda-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/camunda-bpm-users/a8b87759-e63b-4826-b87a-bf7f63dcce0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

thorben....@camunda.com

unread,
Dec 10, 2014, 3:30:54 AM12/10/14
to camunda-...@googlegroups.com
Hi Ingo,

Did you also register the spin engine plugin as described in the user guide linked by Melissa?

What is your deployment scenario? Does this fail within a unit test or when you deploy it to an application server with a shared engine? If the latter is the case, did you make sure the Spin libraries are in the engine's classpath, e.g. on Tomat in the global lib folder (as described in [1] and analogous for the other servers in their respective installation guides)?

If it is none of the above, would you be able to provide a failing test case?

Thanks and best regards,
Thorben

[1] http://docs.camunda.org/latest/guides/installation-guide/tomcat/#bpm-platform-install-optional-camunda-dependencies-install-camunda-spin

Ingo Richtsmeier

unread,
Dec 10, 2014, 8:21:08 PM12/10/14
to camunda-...@googlegroups.com
Thank you, I missed the plugin registration in my camunda.cfg.xml for the unit test.

Now the tests are fine.

Regards, Ingo
Reply all
Reply to author
Forward
0 new messages