<!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: fail to fire a rule task~~ frustrated
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/taitung.wilbert">Guo-Guang Chiou</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/631520#631520">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, Francesco.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>thanks for your reply.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Finally, I found a way to run rule task on jbpm-console.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>here is my process definition..</p><p>=================================================================================</p><p><?xml version="1.0" encoding="UTF-8"?> </p><p><definitions id="Definition"</p><p><span>             targetNamespace="</span><a class="jive-link-external-small" href="http://www.jboss.org/drools" target="_blank">http://www.jboss.org/drools</a><span>"</span></p><p><span>             typeLanguage="</span><a class="jive-link-external-small" href="http://www.java.com/javaTypes" target="_blank">http://www.java.com/javaTypes</a><span>"</span></p><p><span>             expressionLanguage="</span><a class="jive-link-external-small" href="http://www.mvel.org/2.0" target="_blank">http://www.mvel.org/2.0</a><span>"</span></p><p><span>             xmlns="</span><a class="jive-link-external-small" href="http://www.omg.org/spec/BPMN/20100524/MODEL" target="_blank">http://www.omg.org/spec/BPMN/20100524/MODEL</a><span>"</span></p><p><span>             xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"</span></p><p><span>             xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://www.omg.org/spec/BPMN/20100524/MODEL" target="_blank">http://www.omg.org/spec/BPMN/20100524/MODEL</a><span> BPMN20.xsd"</span></p><p><span>             xmlns:g="</span><a class="jive-link-external-small" href="http://www.jboss.org/drools/flow/gpd" target="_blank">http://www.jboss.org/drools/flow/gpd</a><span>"</span></p><p><span>             xmlns:bpmndi="</span><a class="jive-link-external-small" href="http://www.omg.org/spec/BPMN/20100524/DI" target="_blank">http://www.omg.org/spec/BPMN/20100524/DI</a><span>"</span></p><p><span>             xmlns:dc="</span><a class="jive-link-external-small" href="http://www.omg.org/spec/DD/20100524/DC" target="_blank">http://www.omg.org/spec/DD/20100524/DC</a><span>"</span></p><p><span>             xmlns:di="</span><a class="jive-link-external-small" href="http://www.omg.org/spec/DD/20100524/DI" target="_blank">http://www.omg.org/spec/DD/20100524/DI</a><span>"</span></p><p><span>             xmlns:tns="</span><a class="jive-link-external-small" href="http://www.jboss.org/drools" target="_blank">http://www.jboss.org/drools</a><span>"></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  <process processType="Private" isExecutable="true" id="testrule" name="TestRule" tns:packageName="defaultPackage" tns:version="16" ></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    <extensionElements></p><p>     <tns:import name="org.drools.event.*" /></p><p>    </extensionElements></p><p>    <!-- nodes --></p><p>    <startEvent id="_1" name="StartProcess" /></p><p><span>    <scriptTask id="_2" name="Script" scriptFormat="</span><a class="jive-link-external-small" href="http://www.java.com/java" target="_blank">http://www.java.com/java</a><span>" ></span></p><p>      <script>System.out.println("Before rule\n");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>//java.util.Iterator itr = kcontext.getKnowledgeRuntime().getKnowledgeBase().getStatefulKnowledgeSessions().iterator();</p><p>//boolean called = false;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  org.drools.event.AgendaEventListener lis = new org.drools.event.AgendaEventListener(){ </p><p>                                        public void activationCancelled(org.drools.event.ActivationCancelledEvent arg0,</p><p>                                                            org.drools.WorkingMemory arg1) {</p><p>                                        }</p><p>                                        public void activationCreated(org.drools.event.ActivationCreatedEvent arg0,</p><p>                                                            org.drools.WorkingMemory arg1) { </p><p>                                        }</p><p>                                        public void afterActivationFired(</p><p>                                                            org.drools.event.AfterActivationFiredEvent arg0, org.drools.WorkingMemory arg1) {</p><p>                                        }</p><p>                                        public void afterRuleFlowGroupActivated(</p><p>                                                            org.drools.event.RuleFlowGroupActivatedEvent arg0, org.drools.WorkingMemory arg1) {</p><p>                                                  System.out.println("firing all rules");</p><p>                                                  arg1.fireAllRules();</p><p>                                        }</p><p>                                        public void afterRuleFlowGroupDeactivated(</p><p>                                                            org.drools.event.RuleFlowGroupDeactivatedEvent arg0, org.drools.WorkingMemory arg1) {</p><p>                                        }</p><p>                                        public void agendaGroupPopped(org.drools.event.AgendaGroupPoppedEvent arg0,</p><p>                                                            org.drools.WorkingMemory arg1) {</p><p>                                        }</p><p>                                        public void agendaGroupPushed(org.drools.event.AgendaGroupPushedEvent arg0,</p><p>                                                            org.drools.WorkingMemory arg1) {</p><p>                                        }</p><p>                                        public void beforeActivationFired(</p><p>                                                            org.drools.event.BeforeActivationFiredEvent arg0, org.drools.WorkingMemory arg1) {</p><p>                                        }</p><p>                                        public void beforeRuleFlowGroupActivated(</p><p>                                                            org.drools.event.RuleFlowGroupActivatedEvent arg0, org.drools.WorkingMemory arg1) {</p><p>                                        }</p><p>                                        public void beforeRuleFlowGroupDeactivated(</p><p>                                                            org.drools.event.RuleFlowGroupDeactivatedEvent arg0, org.drools.WorkingMemory arg1) {</p><p>                                        }</p><p>                              };</p><p>            </p><p>//if(itr.hasNext())</p><p>//{</p><p>           System.out.println("casting..");</p><p>           org.drools.runtime.StatefulKnowledgeSession ksession = (org.drools.runtime.StatefulKnowledgeSession) kcontext.getKnowledgeRuntime();</p><p>           </p><p>            try{</p><p>           org.drools.impl.StatefulKnowledgeSessionImpl s = (org.drools.impl.StatefulKnowledgeSessionImpl)ksession;</p><p>           s.session.addEventListener(lis)  ;</p><p>           System.out.println("listener is added");</p><p>          //called = true;     </p><p>     }</p><p>     catch(Exception ex)</p><p>     {</p><p>             System.out.println("================================================================================================================");</p><p>               System.out.println(ex.getMessage());     </p><p>                       System.out.println("================================================================================================================");</p><p>     }</p><p>//}</p><p>//if(called==false)</p><p>//{</p><p>//          System.out.println("no session found");   </p><p>//}</script></p><p>    </scriptTask></p><p>    <businessRuleTask id="_3" name="Rule" g:ruleFlowGroup="validate" ></p><p>    </businessRuleTask></p><p>    <endEvent id="_4" name="End" ></p><p>        <terminateEventDefinition/></p><p>    </endEvent></p><p><span>    <scriptTask id="_5" name="Script" scriptFormat="</span><a class="jive-link-external-small" href="http://www.java.com/java" target="_blank">http://www.java.com/java</a><span>" ></span></p><p>      <script> </p><p>System.out.println("Rule Task is done"); </script></p><p>    </scriptTask></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    <!-- connections --></p><p>    <sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2" /></p><p>    <sequenceFlow id="_2-_3" sourceRef="_2" targetRef="_3" /></p><p>    <sequenceFlow id="_5-_4" sourceRef="_5" targetRef="_4" /></p><p>    <sequenceFlow id="_3-_5" sourceRef="_3" targetRef="_5" /></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  </process></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  <bpmndi:BPMNDiagram></p><p>    <bpmndi:BPMNPlane bpmnElement="testrule" ></p><p>      <bpmndi:BPMNShape bpmnElement="_1" ></p><p>        <dc:Bounds x="16" y="16" width="48" height="48" /></p><p>      </bpmndi:BPMNShape></p><p>      <bpmndi:BPMNShape bpmnElement="_2" ></p><p>        <dc:Bounds x="96" y="16" width="80" height="48" /></p><p>      </bpmndi:BPMNShape></p><p>      <bpmndi:BPMNShape bpmnElement="_3" ></p><p>        <dc:Bounds x="208" y="16" width="80" height="48" /></p><p>      </bpmndi:BPMNShape></p><p>      <bpmndi:BPMNShape bpmnElement="_4" ></p><p>        <dc:Bounds x="432" y="16" width="48" height="48" /></p><p>      </bpmndi:BPMNShape></p><p>      <bpmndi:BPMNShape bpmnElement="_5" ></p><p>        <dc:Bounds x="320" y="16" width="80" height="48" /></p><p>      </bpmndi:BPMNShape></p><p>      <bpmndi:BPMNEdge bpmnElement="_1-_2" ></p><p>        <di:waypoint x="40" y="40" /></p><p>        <di:waypoint x="136" y="40" /></p><p>      </bpmndi:BPMNEdge></p><p>      <bpmndi:BPMNEdge bpmnElement="_2-_3" ></p><p>        <di:waypoint x="136" y="40" /></p><p>        <di:waypoint x="248" y="40" /></p><p>      </bpmndi:BPMNEdge></p><p>      <bpmndi:BPMNEdge bpmnElement="_5-_4" ></p><p>        <di:waypoint x="360" y="40" /></p><p>        <di:waypoint x="456" y="40" /></p><p>      </bpmndi:BPMNEdge></p><p>      <bpmndi:BPMNEdge bpmnElement="_3-_5" ></p><p>        <di:waypoint x="248" y="40" /></p><p>        <di:waypoint x="360" y="40" /></p><p>      </bpmndi:BPMNEdge></p><p>    </bpmndi:BPMNPlane></p><p>  </bpmndi:BPMNDiagram></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p></definitions></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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="http://community.jboss.org/message/631520#631520">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>