<!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="http://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: How to make a process instance go on with jBPM5?
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/slelarge">Sebastien Lelarge</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/632793#632793">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Thank you for your answer Melih. I've tried this yesterday but it caused bad results and Transaction related exceptions when I tried to completeWorkItem from the method where I call the complete command with the TaskCient.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>hopefully, I have just found the reason why my process instances refused to go on after session restore and I will share this below.</p><p>Now things seems to be going well after restarts</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>It is possible that some users are in the same situation.</p><p>In mine, the jBPM engine is embedded in a web application and the Human Task server is started from a dedicated servlet (as suggested by bpmn2user in another post) that launches it as a separate thread.</p><p>On the other side, the jBPM engine is initialized (knowledge base and session creation) at application startup in a ServletContextListener.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>What I didn't realize at this time is that the Human Task server is not yet started when I register the "Human Task" worktitem with the ksession...</p><p>It seems (but I am not sure) that the <strong>register command tries to contact the HT server but logs nothing whatever connection result.</strong></p><p>In the case where the HT server is not available, then the WorkItemHandler cannot wake up the persisted workitems correctly. Particularly, when I tried to complete a task, the Task Server returned a "No listeners found" message telling that it didn't have signals to send back to the workflow engine.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Now that I know that, I have rewritten my HumanTask Server servlet in order to proceed to WorkItem registration after the server is correctly started.</p><p>And things are working without manually completing workItem when completing tasks</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Here is a snippet of my start HT server servlet</p><pre class="jive-pre"><code class="jive-code jive-java">logger.info(<font color="red">"Starting jBPM Human Task Server..."</font>);
        taskServerDaemon.startServer(this.port);
        logger.info(<font color="red">"jBPM Human Task Server started."</font>);
       
        <font color="darkgreen">// Get the Knowledge Session initialized at application startup from app context</font>
        <font color="darkgreen">// and register Human Task WorkItem</font>
        logger.info(<font color="red">"Registering Human Task Service for jBPM session."</font>);
        StatefulKnowledgeSession ksession = (StatefulKnowledgeSession)this.getServletContext().getAttribute(ksessionAttribute);
        <font color="navy"><b>if</b></font> (ksession == <font color="navy"><b>null</b></font>) <font color="navy">{</font>
            logger.error(<font color="red">"The retrieved ksession is null. Cannot continue"</font>);
        <font color="navy">}</font> <font color="navy"><b>else</b></font> <font color="navy">{</font>
            CommandBasedWSHumanTaskHandler wsht = <font color="navy"><b>new</b></font> CommandBasedWSHumanTaskHandler(ksession);
           
            <font color="navy"><b>try</b></font> <font color="navy">{</font>
                hostname = InetAddress.getLocalHost().getHostName();
            <font color="navy">}</font> <font color="navy"><b>catch</b></font> (UnknownHostException uhe) <font color="navy">{</font>
                logger.error(<font color="red">"Unable to resolve local host IP"</font>);
            <font color="navy">}</font>
            wsht.setConnection(this.hostname, this.port);
            wsht.connect();
            ksession.getWorkItemManager().registerWorkItemHandler(<font color="red">"Human Task"</font>, wsht);
            logger.info(<font color="red">"Human Task Service for jBPM session "</font> + ksession.getId() + <font color="red">" is registered"</font>);
        <font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I hope this can help</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/632793#632793">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="http://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>