<!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;">
    NullPointerException problem when console tried to start new sub process, triggered by signal sent from async task
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/brucecui">Bruce Cui</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/613255#613255">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I know the subject is not quite clear. But problem itself does look that complex to me. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Here is a background brief:</p><p>I tried to use jBPM to drive some backend batch processes, which basically requires multi-threading. After struggling with various problems, asking around in the forum, changing and rebuilding source codes, I finally came to this stage: the console can now pass ksession(actually kruntime) to my self-defined work item handlers, and I can trigger the event by calling ksession's signal method with return value to the processInstance.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This was suppose to be a maybe not perfect, but at least a working solution. But problems just come after another. Now I found that once the process contains sub process, it would throw out NullPointerException at the point when trying to add the sub process to persistance: "org.jbpm.persistence.processinstance.JPAProcessInstanceManager.addProcessInstance(JPAProcessInstanceManager.java:37)".</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Another question is, I found that when I called the signalEvent method of the ksession, it actually took over the process and run the rest in this thread. So, say if I have a infinite loop, and an async task runs every round, and an signal event starts after it waiting for return event. If the task calls the signalEvent method every time, once a new thread takes over the process, will the old thread end? Or it will keep accumulating?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Below is the log output of the first problem:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">2011-07-04 19:13:01,092 INFO&#160; [STDOUT] (Thread-107) kruntime: org.drools.impl.StatefulKnowledgeSessionImpl@7b2b39
2011-07-04 19:13:01,092 INFO&#160; [STDOUT] (Thread-107) process: WorkflowProcessInstance8 [processId=com.xxxx.CustomerLoader,state=1]
2011-07-04 19:13:01,092 INFO&#160; [STDOUT] (Thread-107) process instance id: 8
2011-07-04 19:13:01,092 INFO&#160; [STDOUT] (Thread-107) File collector done. Signal out
2011-07-04 19:13:01,107 INFO&#160; [STDOUT] (Thread-107) Collector Event Received
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107) Exception in thread "Thread-107" 
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107) org.drools.RuntimeDroolsException: Unexpected exception executing action org.jbpm.process.instance.event.DefaultSignalManager$SignalProcessInstanceAction@c5ab84
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:996)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.drools.impl.StatefulKnowledgeSessionImpl.executeQueuedActions(StatefulKnowledgeSessionImpl.java:845)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.process.instance.event.DefaultSignalManager.signalEvent(DefaultSignalManager.java:89)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.process.instance.ProcessRuntimeImpl.signalEvent(ProcessRuntimeImpl.java:359)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.drools.impl.StatefulKnowledgeSessionImpl.signalEvent(StatefulKnowledgeSessionImpl.java:327)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at com.sample.FileCollector.run(FileCollector.java:74)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107) Caused by: java.lang.NullPointerException
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.addProcessInstance(JPAProcessInstanceManager.java:37)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.process.instance.AbstractProcessInstanceFactory.createProcessInstance(AbstractProcessInstanceFactory.java:36)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:168)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.process.instance.ProcessRuntimeImpl.createProcessInstance(ProcessRuntimeImpl.java:140)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:121)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1095)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:306)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.node.SubProcessNodeInstance.internalTrigger(SubProcessNodeInstance.java:121)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:185)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.node.SplitInstance.internalTrigger(SplitInstance.java:129)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:185)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:150)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.node.JoinInstance.triggerCompleted(JoinInstance.java:152)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.node.JoinInstance.internalTrigger(JoinInstance.java:52)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:185)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.node.SplitInstance.internalTrigger(SplitInstance.java:129)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:185)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:150)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.node.JoinInstance.triggerCompleted(JoinInstance.java:152)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.node.JoinInstance.internalTrigger(JoinInstance.java:52)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:185)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:150)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.node.ActionNodeInstance.triggerCompleted(ActionNodeInstance.java:55)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.node.ActionNodeInstance.internalTrigger(ActionNodeInstance.java:51)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:185)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:150)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.node.ActionNodeInstance.triggerCompleted(ActionNodeInstance.java:55)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.node.ActionNodeInstance.internalTrigger(ActionNodeInstance.java:51)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:185)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:150)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.node.EventNodeInstance.triggerCompleted(EventNodeInstance.java:66)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.node.EventNodeInstance.signalEvent(EventNodeInstance.java:50)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.signalEvent(WorkflowProcessInstanceImpl.java:353)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jbpm.process.instance.event.DefaultSignalManager$SignalProcessInstanceAction.execute(DefaultSignalManager.java:117)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:994)
2011-07-04 19:13:01,138 ERROR [STDERR] (Thread-107)&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;... 5 more

</code></pre></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/613255#613255">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>