<!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;">
taskId of user task is cumulating
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/fellowtom">Thomas Colditz</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/828650#828650">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hi all,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>this is my first post here, since I'm pretty new with jbpm and bpm in general. Installation worked fine and trying one of the example processes is fine as well.</p><p>So I tried to set up my own process wich just consists of Start->script->user->script->end, to get a little "deeper" training. The code is (almost) the same compared to EvaluationExample2.</p><p>But I just wanted to complete 1 user task, no gateways or anything else. Long sentence short, it works fine ONCE. </p><p>Im using jBPM 6. Here's the code:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>     </p><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>public</b></font> <font color="navy"><b>static</b></font> <font color="navy"><b>void</b></font> main(String[] args) <font color="navy"><b>throws</b></font> Exception<font color="navy">{</font>
          <font color="navy"><b>try</b></font><font color="navy">{</font>
                    RuntimeManager manager = getRuntimeManager(<font color="red">"process_1.bpmn"</font>);       
                    RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
                    KieSession ksession = runtime.getKieSession();
 
                <font color="darkgreen">// start a new process instance</font>
                    Map<String, Object> params = <font color="navy"><b>new</b></font> HashMap<String, Object>();
                    params.put(<font color="red">"worker"</font>, <font color="red">"user1"</font>);
                    ksession.startProcess(<font color="red">"process_1.bpmn"</font>, params);
 
                <font color="darkgreen">// the first task</font>
                    TaskService tser = runtime.getTaskService();
                    TaskSummary tsum = taskService.getTaskAssignedAsPotentialOwner(<font color="red">"user1"</font>, <font color="red">"en-UK"</font>).get(0);
                System.out.println(tsum.getId());
                taskService.start(tsum.getId(), <font color="red">"user1"</font>);
                    taskService.complete(tsum.getId(), <font color="red">"user1"</font>, <font color="navy"><b>null</b></font>);
 
                    manager.disposeRuntimeEngine(runtime);
               <font color="navy">}</font> <font color="navy"><b>catch</b></font> (Throwable t) <font color="navy">{</font>
                         t.printStackTrace();
               <font color="navy">}</font>
               System.exit(0);
               <font color="navy">}</font>
 
               <font color="navy"><b>private</b></font> <font color="navy"><b>static</b></font> RuntimeManager getRuntimeManager(String process) <font color="navy">{</font>
                    <font color="darkgreen">// load up the knowledge base</font>
                    JBPMHelper.startH2Server();
                       JBPMHelper.setupDataSource();
                       Properties properties= <font color="navy"><b>new</b></font> Properties();
                    properties.setProperty(<font color="red">"krisv"</font>, <font color="red">""</font>);
                    properties.setProperty(<font color="red">"mary"</font>, <font color="red">"HR"</font>);
                    properties.setProperty(<font color="red">"john"</font>, <font color="red">"PM"</font>);
                    UserGroupCallback userGroupCallback = <font color="navy"><b>new</b></font> JBossUserGroupCallbackImpl(properties);
                    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.getDefault()
                         .userGroupCallback(userGroupCallback)
                         .addAsset(ResourceFactory.newClassPathResource(process), ResourceType.BPMN2)
                         .get();
                    <font color="navy"><b>return</b></font> RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
               <font color="navy">}</font>
<font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The error is the following: User '[UserImpl: 'user1']' was unable to execution operation 'Start' on task id 4 due to a no 'current status' match.</p><p>So everytime I:</p><p>          - change the string of employee (e.g. "user1" to "user2"), it works ONCE again, but the taskId is summating (every time I try to run, its getting taskId++;). BTW the taskId should be 4. </p><p>          - delete the jbpm-db.h2.db, it works fine again ONCE, but the taskId starts at 1. </p><p>          - run the EvaluationExample2 in between, I can run my process again once. A second time fails (Example runs multiple times), but taskId is always 4 like it should. So this seems to 'reset' my problem.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>So I hope I could explain my Problem and I'm sure its a very simple one for you. (probably just a db setup)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>With kind regards!</p><p>Greetings,</p><p>FellowTom</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/828650#828650">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>