0 Replies Latest reply on Mar 16, 2018 12:09 PM by RAFAEL PINO

    Start process instance with a List of custom objects parameters

    RAFAEL PINO Newbie



      I'm trying to start a process instance passing a List of custom objects using a parameter Map. The process instance is started but when I open the Form that uses the List of objects, then the server throws the following exception:


      2018-03-15 16:20:33,587 INFO  [stdout] (default task-18) Error showing CreateDynamicObject input javax.servlet.jsp.JspException: java.lang.ClassCastException: java.util.ArrayList cannot be cast to [Ljava.lang.Object;

      2018-03-15 16:20:33,601 ERROR [stderr] (default task-18) javax.servlet.jsp.JspException: java.lang.ClassCastException: java.util.ArrayList cannot be cast to [Ljava.lang.Object;


      I have attached the .jar file containing the project artifacts.


      Here is the code that I'm using to start the process:


      import java.net.MalformedURLException;

      import java.net.URL;

      import java.util.ArrayList;

      import java.util.HashMap;

      import java.util.List;

      import java.util.Map;


      import org.junit.Test;

      import org.kie.api.runtime.KieSession;

      import org.kie.api.runtime.manager.RuntimeEngine;

      import org.kie.api.runtime.process.ProcessInstance;

      import org.kie.remote.client.api.RemoteRuntimeEngineFactory;


      import com.fasterxml.jackson.databind.ObjectMapper;

      import com.hardnetics.loader.process.DocumentBO;

      import com.hardnetics.loader.process.DocumentValidationRequirementBO;


      public class TestRestAPI {


        private void startProcessAndHandleTaskViaRestRemoteJavaAPI(URL instanceUrl, String deploymentId, String user,

        String password) {

        // Setup the factory class with the necessarry information to communicate with

        // the REST services

        RuntimeEngine engine = RemoteRuntimeEngineFactory






        .addExtraJaxbClasses(DocumentBO.class, DocumentValidationRequirementBO.class)


        // Create KieSession and TaskService instances and use them

        KieSession ksession = engine.getKieSession();

        // sends a request for the operation to the server side and waits for the

        // response


        // If something goes wrong on the server side, the client will throw an

        // exception.

        try {

        Map<String, Object> params = new HashMap<String, Object>();

        DocumentValidationRequirementBO documents = new DocumentValidationRequirementBO();


        DocumentBO document = new DocumentBO();

        List<DocumentBO> docs = new ArrayList<>();

        ObjectMapper oMapper = new ObjectMapper();






                params.put("input", oMapper.convertValue(documents, Map.class));

        ProcessInstance processInstance = ksession.startProcess("LoaderProcess.ValidateDocumentBP",params);

        } catch (Exception e) {






        public void test() {

        String deploymentId = "com.hardnetics.loader:process:1.0";

        String user = "admin";

        String password = "admin";

        URL host;

        try {

        host = new URL("http://localhost:8080/jbpm-console");

        startProcessAndHandleTaskViaRestRemoteJavaAPI(host, deploymentId, user, password);

        } catch (MalformedURLException e) {

        // TODO Auto-generated catch block








      Please, anyone can tell me what I'm doing wrong?. How can I pass a List of custom objects as parameter and open it successfully using a Form?.


      Thank you.