<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Re: JBPM 5.4.0-Final: Human Task variable mapping is not working
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/maq99">maq99</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/792774#792774">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hallo,</p><p>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.</p><p>Here is my diagram: </p><p><a href="https://community.jboss.org/servlet/JiveServlet/showImage/2-792774-20169/Diagram.gif"><span> https://community.jboss.org/servlet/JiveServlet/downloadImage/2-792774-20169/450-120/Diagram.gif </span></a></p><p>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. </p><p>First gateway check if object have been placed (not null - go to commit) or changes have been rejected (is null - cancel &amp; end process) </p><p>At begininig next HT (approval) fallowing log script is called, then it calls my custom <code>EscalatedDeadlineHandler</code> and send email to user:approver that he has task assign. Approval base on object:wrapper from previous HT.</p><p>Approvel page display edited object:wrapper and shows changes made by user:user1</p><p>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. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>process variables: </p><p>Name: wrapper; Type: Object; ClassName: Object</p><p>Name: isApproved; Type: Object; ClassName: Object</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>1HT (edit object) Result mapping:</p><p>Parameter: result; Variable: wrapper</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>1Gateway:</p><p>commit: Type: code; Dialect: mvel; wrapper!=null</p><p>cancel:&#160; Type: code; Dialect: mvel; wrapper==null</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>2HT (approval) Parameter mapping:</p><p>Parameter wrapper; Variable: wrapper;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>2HT (approval) Result mapping:</p><p>Parameter isApproved; Variable: isApproved;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Starting process code:</p><p>@PersistenceUnit(unitName = "org.jbpm.persistence.jpa")</p><p>protected EntityManagerFactory jbpmPersistence;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@PersistenceUnit(unitName = "org.jbpm.task")</p><p>protected EntityManagerFactory jbpmTask;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>(...)</p><p>Environment env = EnvironmentFactory.newEnvironment();</p><p>env.set(EnvironmentName.TRANSACTION_MANAGER,TransactionManagerServices.getTransactionManager());</p><p>env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);</p><p>env.set(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES,</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;new ObjectMarshallingStrategy[] {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;new JPAPlaceholderResolverStrategy(env),</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;new SerializablePlaceholderResolverStrategy(</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ClassObjectMarshallingStrategyAcceptor.DEFAULT) });</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();</p><p>kbuilder.add(ResourceFactory.newClassPathResource(bpmn),ResourceType.BPMN2);</p><p>// Check for errors</p><p>if (kbuilder.hasErrors()) {</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;if (kbuilder.getErrors().size() &gt; 0) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for (KnowledgeBuilderError error : kbuilder.getErrors()) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;log.error(error.toString());</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;}</p><p>}</p><p>KnowledgeBase kbase = kbuilder.newKnowledgeBase();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>KnowledgeSessionConfiguration conf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, conf, env);</p><p>KnowledgeRuntimeLogger knowledgeRuntimeLogger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "test", 1000);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>MyHtWorkItemHandler workItemHandler = new MyHtWorkItemHandler(</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ksession);</p><p>workItemHandler.setLocal(true);</p><p>workItemHandler.setIpAddress(WUIConfiguration.getHumanTaskServiceIP());</p><p>workItemHandler.setPort(WUIConfiguration.getHumanTaskServicePort());</p><p>workItemHandler.setClient(getLocalTaskService());</p><p>ksession.getWorkItemManager().registerWorkItemHandler("Human Task",</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;workItemHandler);</p><p>workItemHandler.connect();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.startProcess(processId);// variables will be added in HT.. .</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>protected TaskService getLocalTaskService() {</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;if (taskService == null) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;taskService = new org.jbpm.task.service.TaskService(jbpmTask,</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SystemEventListenerFactory.getSystemEventListener());</p><p>//for PoC it can be singleton? </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;taskService</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.setEscalatedDeadlineHandler(MyEscalatedDeadlineHandler</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.getInstance());</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;TaskServiceSession taskServiceSession = taskService.createSession();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;// TODO create dynamic users list..</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;taskServiceSession.addUser(new User("approver"));</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;taskServiceSession.addUser(new User("user1"));</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;}</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;// taskservicesMap.put(processName, taskService);</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;return new LocalTaskService(taskService);</p><p>}</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/792774#792774">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>