JBoss Community

Re: JBPM 5.4.0-Final: Human Task variable mapping is not working

created by vchmakov in jBPM - View the full discussion

Hi Maciej,

Your proposed approach works fine in terms that the my process now sees the result values. However, when the time comes for the session to complete the tasks is fails. I suspect the reason for this is the same – different persistent context.

        private void handleCompletedTask(long taskId) {

// currentClient is a reference to my LocalTaskService instance I create for completeting the tasks

            Task task = currentClient.getTask(taskId);

            long workItemId = task.getTaskData().getWorkItemId();

            if (task.getTaskData().getStatus() == Status.Completed) {

                String userId = task.getTaskData().getActualOwner().getId();

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

                results.put("ActorId", userId);

                long contentId = task.getTaskData().getOutputContentId();

                if (contentId != -1) {

                    Content content = currentClient.getContent(contentId);

                    Object result = ContentMarshallerHelper.unmarshall(content.getContent(), session.getEnvironment());

                    results.put("Result", result);

                    if (result instanceof Map) {

                        Map<?, ?> map = (Map<?, ?>) result;

                        for (Map.Entry<?, ?> entry : map.entrySet()) {

                            if (entry.getKey() instanceof String) {

                                results.put((String) entry.getKey(), entry.getValue());

                            }

                        }

                    }

è  fails here

                    session.getWorkItemManager().completeWorkItem(task.getTaskData().getWorkItemId(), results);

                }

                else {

                    session.getWorkItemManager().completeWorkItem(workItemId, results);

                }

            }

            else {

                logger_processes.debug("session.getWorkItemManager().abortWorkItem()");

                session.getWorkItemManager().abortWorkItem(workItemId);

            }

        }

processTaskCommand() error:: com.thoughtworks.xstream.io.StreamException:  : only whitespace content allowed before start tag and not B (position: START_DOCUMENT seen B... @1:1)

                at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:124) [xstream-1.4.1.jar:]

                at com.thoughtworks.xstream.io.xml.AbstractPullReader.readRealEvent(AbstractPullReader.java:148) [xstream-1.4.1.jar:]

                at com.thoughtworks.xstream.io.xml.AbstractPullReader.readEvent(AbstractPullReader.java:141) [xstream-1.4.1.jar:]

                at com.thoughtworks.xstream.io.xml.AbstractPullReader.move(AbstractPullReader.java:118) [xstream-1.4.1.jar:]

                at com.thoughtworks.xstream.io.xml.AbstractPullReader.moveDown(AbstractPullReader.java:103) [xstream-1.4.1.jar:]

                at com.thoughtworks.xstream.io.xml.XppReader.<init>(XppReader.java:63) [xstream-1.4.1.jar:]

                at com.thoughtworks.xstream.io.xml.AbstractXppDriver.createReader(AbstractXppDriver.java:58) [xstream-1.4.1.jar:]

                at com.thoughtworks.xstream.XStream.fromXML(XStream.java:895) [xstream-1.4.1.jar:]

                at com.thoughtworks.xstream.XStream.fromXML(XStream.java:886) [xstream-1.4.1.jar:]

                at org.drools.process.core.datatype.impl.type.ObjectDataType.readValue(ObjectDataType.java:77) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                at org.jbpm.workflow.instance.node.WorkItemNodeInstance.triggerCompleted(WorkItemNodeInstance.java:223) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.workflow.instance.node.HumanTaskNodeInstance.triggerCompleted(HumanTaskNodeInstance.java:90) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.workflow.instance.node.WorkItemNodeInstance.workItemCompleted(WorkItemNodeInstance.java:309) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.workflow.instance.node.WorkItemNodeInstance.signalEvent(WorkItemNodeInstance.java:285) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.signalEvent(WorkflowProcessInstanceImpl.java:342) [jbpm-flow-5.4.0.Final.jar:5.4.0.Final]

                at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.completeWorkItem(JPAWorkItemManager.java:121) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.command.runtime.process.CompleteWorkItemCommand.execute(CompleteWorkItemCommand.java:69) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.command.runtime.process.CompleteWorkItemCommand.execute(CompleteWorkItemCommand.java:32) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:373) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.command.impl.CommandBasedStatefulKnowledgeSession$1.completeWorkItem(CommandBasedStatefulKnowledgeSession.java:150) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                at BvLocalHTWorkItemHandler$TaskCompletedHandler.handleCompletedTask(BvLocalHTWorkItemHandler.java:96)

It seems like either I need to put Drools and Task Service inside the same persistent context or split the transaction boundaries between Drools and Task Service. The second one is in fact a recommended way here which has been previously discussed in another posts, but I strongly disagree with the Task Service decoupling idea.

Any other thoughts/ideas?

Thanks,

Vladimir

 



Reply to this message by going to Community

Start a new discussion in jBPM at Community