[jboss-user] [jBPM] - Re: JBPM 5.4.0-Final: Human Task variable mapping is not working

maq99 do-not-reply at jboss.com
Fri Jan 18 06:04:48 EST 2013

maq99 [https://community.jboss.org/people/maq99] created the discussion

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

To view the discussion, visit: https://community.jboss.org/message/792774#792774

I have simmilar problem and decide to add my post to this topic instead create new one. Something wrong is with saveing variables. I already spend some time on it and have not found sollution. All base on seam framework (web app) + EJB3 as jbpm managment layer. Persistence is made on Postgres.
Here is my diagram: 
 https://community.jboss.org/servlet/JiveServlet/showImage/2-792774-20169/Diagram.gif  https://community.jboss.org/servlet/JiveServlet/downloadImage/2-792774-20169/450-120/Diagram.gif 
As You can see there is two human tasks.. After process is started user:user1 pick object:wrapper (from external Wsdl) to edit, chenge its fields and confirm changes or reject it. Eddited object is about to be placed as HT result and stored as process variables. 
First gateway check if object have been placed (not null - go to commit) or changes have been rejected (is null - cancel & end process) 
At begininig next HT (approval) fallowing log script is called, then it calls my custom EscalatedDeadlineHandler and send email to user:approver that he has task assign. Approval base on object:wrapper from previous HT.
Approvel page display edited object:wrapper and shows changes made by user:user1
As a result Boolean value isApproved has to be added to proces variables. Next gateway check isApproved on true go to submit changes (send back to store edited object - external Wsdl) - else goes to end. 

process variables: 
Name: wrapper; Type: Object; ClassName: Object
Name: isApproved; Type: Object; ClassName: Object

1HT (edit object) Result mapping:
Parameter: result; Variable: wrapper

commit: Type: code; Dialect: mvel; wrapper!=null
cancel:  Type: code; Dialect: mvel; wrapper==null

2HT (approval) Parameter mapping:
Parameter wrapper; Variable: wrapper;

2HT (approval) Result mapping:
Parameter isApproved; Variable: isApproved;

Starting process code:
@PersistenceUnit(unitName = "org.jbpm.persistence.jpa")
protected EntityManagerFactory jbpmPersistence;

@PersistenceUnit(unitName = "org.jbpm.task")
protected EntityManagerFactory jbpmTask;

Environment env = EnvironmentFactory.newEnvironment();
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
          new ObjectMarshallingStrategy[] {
                    new JPAPlaceholderResolverStrategy(env),
                    new SerializablePlaceholderResolverStrategy(
                              ClassObjectMarshallingStrategyAcceptor.DEFAULT) });

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
// Check for errors
if (kbuilder.hasErrors()) {
          if (kbuilder.getErrors().size() > 0) {
                    for (KnowledgeBuilderError error : kbuilder.getErrors()) {
KnowledgeBase kbase = kbuilder.newKnowledgeBase();

KnowledgeSessionConfiguration conf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();

StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, conf, env);
KnowledgeRuntimeLogger knowledgeRuntimeLogger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "test", 1000);

MyHtWorkItemHandler workItemHandler = new MyHtWorkItemHandler(
ksession.getWorkItemManager().registerWorkItemHandler("Human Task",

WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession
                                        .startProcess(processId);// variables will be added in HT.. .

protected TaskService getLocalTaskService() {
          if (taskService == null) {
                    taskService = new org.jbpm.task.service.TaskService(jbpmTask,
//for PoC it can be singleton? 
                    TaskServiceSession taskServiceSession = taskService.createSession();
                    // TODO create dynamic users list..
                    taskServiceSession.addUser(new User("approver"));
                    taskServiceSession.addUser(new User("user1"));
          // taskservicesMap.put(processName, taskService);
          return new LocalTaskService(taskService);

Reply to this message by going to Community

Start a new discussion in jBPM at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130118/3759bd40/attachment-0001.html 

More information about the jboss-user mailing list