Issue in Starting JBPM process with custom object as process variable
scatiza Aug 5, 2019 7:46 AM
I am new to Jbpm
I have created a workflow in JBPM with business flow having rules and Human task . The workflow accepts a process variable which is a customer object ( Class name Quote) . If I start the workflow using Kie Workbech ,it works fine but when I am trying to start the process from REST API of the Client API , is sends me error as
" "Unexpected HTTP response code when requesting URI
Error code: 500, message: \"Unable to create response: [QuoteManagedRules.quoteManagedRules:181 - Quote received:7] -- java.util.LinkedHashMap cannot be cast to com.myspace.quotemanagedrules.QuoteDto\"","
I have tried debugging and turn out that instead of a custom object , if I using String or any other literals it works fine but with the process variable as an Object , it shows error
public static final String SERVER_URL="http://localhost:8080/kie-server/services/rest/server";
public static final String LOGIN="wbadmin";
public static final String PASSWORD="wbadmin";
public static final String CONTAINER="QuoteManagedRules_1.0.0-SNAPSHOT";
public static final String processId="QuoteManagedRules.quoteManagedRules";
public static void startProcess()
{ //Client configuration setup
KieServicesConfiguration config = KieServicesFactory.newRestConfiguration(SERVER_URL, LOGIN, PASSWORD);
//Add custom classes, such as Obj.class, to the configuration
Set<Class<?>> extraClassList = new HashSet<Class<?>>();
extraClassList.add(QuoteDto.class);
config.addExtraClasses(extraClassList);
config.setMarshallingFormat(MarshallingFormat.JSON);
// ProcessServicesClient setup
KieServicesClient client = KieServicesFactory.newKieServicesClient(config);
ProcessServicesClient processServicesClient = client.getServicesClient(ProcessServicesClient.class);
// Create an instance of the custom class
QuoteDto obj = new QuoteDto();
obj.setAccountId("1");
obj.setCorrelationId("1");
obj.setId("12");
obj.setOppurtunityId("123");
obj.setOppurtunityName("sattu");
obj.setPrice(123);
obj.setRevision(12);
obj.setVersion("12");
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("quote", obj);
// Start the process with custom class
processServicesClient.startProcess(CONTAINER, processId, variables); }
The above code should start the process . Please let me know how to fix this . Do I need to mention the QuoteDto Class anywhere else as well in order to map it correctly like in kmodule.xml or so ?