1 Reply Latest reply on Feb 20, 2013 4:28 AM by John Joel Boss

    Drools/jBPM integration problem - firing drools rules from rule task node

    John Joel Boss Newbie

      Hi all,

       

      I have read from https://community.jboss.org/message/627263 that to fire the rule, I must call fireAllRules() before the rule task node and so I added the listener sugested in the same thread:

       

      final org.drools.event.AgendaEventListener agendaEventListener = new org.drools.event.AgendaEventListener() {

                  public void activationCreated(ActivationCreatedEvent event,

                          WorkingMemory workingMemory){

                  }

                  public void activationCancelled(ActivationCancelledEvent event,

                            WorkingMemory workingMemory){

                  }

                  public void beforeActivationFired(BeforeActivationFiredEvent event,

                              WorkingMemory workingMemory) {

                  }

                  public void afterActivationFired(AfterActivationFiredEvent event,

                             WorkingMemory workingMemory) {

                  }

                  public void agendaGroupPopped(AgendaGroupPoppedEvent event,

                          WorkingMemory workingMemory) {

                  }

       

       

                  public void agendaGroupPushed(AgendaGroupPushedEvent event,

                          WorkingMemory workingMemory) {

                  }

                  public void beforeRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event,

                                     WorkingMemory workingMemory) {

                  }

                  public void afterRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event,

                          WorkingMemory workingMemory) {

                      workingMemory.fireAllRules();

                  }

                  public void beforeRuleFlowGroupDeactivated(RuleFlowGroupDeactivatedEvent event,

                                       WorkingMemory workingMemory) {

                  }

                  public void afterRuleFlowGroupDeactivated(RuleFlowGroupDeactivatedEvent event,

                                      WorkingMemory workingMemory) {

                  }

              };

              ((StatefulKnowledgeSessionImpl)  ((KnowledgeCommandContext) ((CommandBasedStatefulKnowledgeSession) ksession)

                      .getCommandService().getContext()).getStatefulKnowledgesession() )

                      .session.addEventListener(agendaEventListener);

       

       

      However, I am getting the following cast error:

       

      Exception in thread "main" java.lang.ClassCastException: org.drools.impl.StatefulKnowledgeSessionImpl cannot be cast to org.drools.command.impl.CommandBasedStatefulKnowledgeSession

                at com.sample.ProcessMain.main(ProcessMain.java:79)

       

      Can anyone help please? I'm using jBPM 5.4 with Drools 5.5.0