1 2 Previous Next 20 Replies Latest reply on Mar 29, 2013 1:56 PM by ouadi_dev Go to original post
      • 15. Re: How to set a process variable from java code ?
        ouadi_dev

        Here is my compete taskmethod code :

         

        TaskClient client = null;
        
        try {
              client = connectToTaskServer(TASK_SERVER_HOST_IP_ADD,
                                                          TASK_SERVER_PORT);
        
              BlockingTaskOperationResponseHandler responseHandler = new BlockingTaskOperationResponseHandler();
        
             Map<String, Object> taskVariables = new HashMap<String, Object>();
             // Currency validation accepted
        
             taskVariables.put("o_validationResult", true);
        
        
              client.completeWithResults(aTaskId, aOwnerId, taskVariables, responseHandler);
        
              responseHandler.waitTillDone(2000);
          
              client.disconnect();
        
        
        } catch (Exception e) {
            try {
                  client.disconnect();
            } catch (Exception e1) {
                 e1.printStackTrace();
            }
              e.printStackTrace();
              logger.error("Unable to completing the Task '" + aTaskId
                                 + "' assigned to user '" + aOwnerId + "' : " + e.toString());
              throw new TaskManagerException("Unable to completing the Task '"
                                 + aTaskId + "' assigned to user '" + aOwnerId + "' : "
                                 + e.toString(), e);
        }
        

         

        After hard searching in the net, I'm not able to detect where this exception triggered !

         

        Here is exception javadoc :

         

        http://docs.oracle.com/javase/6/docs/api/java/io/OptionalDataException.html

         

        Thanks in advance.

        • 16. Re: How to set a process variable from java code ?
          ouadi_dev

          I've find the solution of this probelm.

           

          In order to solve this problem, we need to use this version of task complete method:

           

           

              BlockingTaskOperationResponseHandler responseHandler = new BlockingTaskOperationResponseHandler();
          
             Map<String, Object> taskVariables = new HashMap<String, Object>();
             taskVariables.put(new String("o_validationResult"),Boolean.valueOf(true));
          
            ContentData contentData = null;
              ByteArrayOutputStream bos = new ByteArrayOutputStream();
              ObjectOutputStream out;
              try {
                out = new ObjectOutputStream(bos);
                out.writeObject(taskVariables);
                out.close();
                contentData = new ContentData();
                contentData.setContent(bos.toByteArray());
                contentData.setAccessType(AccessType.Inline);
              } catch (IOException ioe) {
                           ioe.printStackTrace();
              }
          
              client.complete(aTaskId, aOwnerId, contentData, responseHandler);
          
          

           

          With this code the task completion with a map of variables must done successfully.

          • 17. Re: How to set a process variable from java code ?
            swiderski.maciej

            if that code resolved your issue please double check if you use 5.4 libraries as that approach was used before 5.4

             

            HTH

            • 18. Re: How to set a process variable from java code ?
              ouadi_dev

              Yes, of course I use jBPM 5.4 and Drools 5.5.0

              • 19. Re: How to set a process variable from java code ?
                swiderski.maciej

                all ht related operations in 5.4 are based on ContentMarshallerHelper and thus serializing it with ObjectOutputStream will not work unless you use deprecated HT work item handler that uses ObjectInputStream for serialization. So question is what HT work item handler do you use?

                • 20. Re: How to set a process variable from java code ?
                  ouadi_dev

                  I use CommandBasedWSHumanTaskHandler

                  1 2 Previous Next