1 Reply Latest reply on Nov 16, 2013 1:27 PM by Massimiliano Diodati

    jBPM How to get variables of terminated processes

    Massimiliano Diodati Newbie

      Hi all!

      In my webapplication I need to show data of terminated processes (other than data of active ones). I am able to retrieve the process instance Id of the terminated process but using the following code I get the declared exception:


      public static Map<String, Object> getProcessInstanceVariables(String processInstanceId) throws Exception{

              ksession = getSession();

              ProcessInstance processInstance = ksession.getProcessInstance(new Long(processInstanceId));

              if (processInstance != null) {

              Map<String, Object> variables =

              ((WorkflowProcessInstanceImpl) processInstance).getVariables();

                          if (variables == null) {

              return new HashMap<String, Object>();


              // filter out null values

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

              for (Map.Entry<String, Object> entry: variables.entrySet()) {

              if (entry.getValue() != null) {

              result.put(entry.getKey(), entry.getValue());



              return result;

              } else {

              throw new IllegalArgumentException("Could not find process instance " + processInstanceId);




      The problem seems to be that the ksession only sees the avtive processes (the PROCESSINSTANCEINFO table in the db).

      Does anyone know how to get the variables of the terminated processes? This is a very crucial issue for my application!


      P.S.: I tryed querying the db directly, but it is locked by the webapp.


      Thanks in advance.

        • 1. Re: jBPM How to get variables of terminated processes
          Massimiliano Diodati Newbie

          Nevermind, I found the way to get variables browsing the API. For those who might find this topic interesting, here is the code to get the process variable "offerId":


          List<ProcessInstanceLog> processDetail = null;



                      processDetail = JPAProcessInstanceDbLog.findProcessInstances();



                  catch(Exception e)




                  for (int i=0; i<processDetail.size();i++){

                      long piid=processDetail.get(i).getId();

                      List<VariableInstanceLog> variables=JPAProcessInstanceDbLog.findVariableInstances(piid);

                      for (int j=0;j<variables.size();j++){


                          String variableId = variables.get(j).getVariableId();


                              String offerId = variables.get(j).getValue();