JBoss Community

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

created by John Joel Boss in jBPM - View the full discussion

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

Reply to this message by going to Community

Start a new discussion in jBPM at Community