cancel
Showing results for 
Search instead for 
Did you mean: 

Integrate Activiti with Drools

ridottiastozze
Champ in-the-making
Champ in-the-making
Hi,
I have to integrate Activiti with the Drools Engine for my thesis but I have some problems.
I have inserted in the Activiti Explorer the .bar file, that contains the .bpmn20.xml process and the .drl file.  Looking in one previus post   I notice that you gave some advices:

1. The drools-api, drools-compiler, drools-core and mvel2 jar files are missing from the activiti-rest application, so you have to add those manually.  (I have inserted the .jar in C:\activiti-5.8\apps\apache-tomcat-6.0.32\webapps\activiti-rest\WEB-INF\lib folder)
2. In the activiti-cfg.xml inside the activiti-cfg.jar in the activiti-rest application you have to include the following property:
<property name="customPostDeployers">
<list>
<bean class="org.activiti.engine.impl.rules.RulesDeployer" />
</list>
</property>
(it seems ok)


When I run the process in the Activiti Explorer tomcat gives me this exception:
Cause: org.activiti.engine.ActivitiException: couldn't find type for RuleInput

This is the code:
<process id="processSalary" name="processSalary">
    <startEvent id="startevent1" name="Start" activiti:initiator="employeeName>
    <extensionElements>       
     <activiti:formProperty id="salary" name="Insert the salary" type="long" required="true"/>
     <activiti:formProperty id="age" name="Insert the age" type="long" required="true"/>
     </extensionElements>
    </startEvent>
<serviceTask id="servicetask1" name="Service Task" activiti:class="org.activiti.demo.rules.CreateRuleObjectDelegate"></serviceTask>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
    <businessRuleTask id="businessruletask1" name="Business rule task" activiti:rules="salarycheck" activiti:ruleVariablesInput="${ruleInput}" activiti:exclude="false" activiti:resultVariableName="ruleOutput"></businessRuleTask>

public class CreateRuleObjectDelegate implements JavaDelegate {

  public void execute(DelegateExecution execution) throws Exception {
     RuleInput ruleInput = new RuleInput();   
       ruleInput.setEmployee((String) execution.getVariable("employeeName"));
       Long salario, age;
       salario = (Long)execution.getVariable("salary");
       age = (Long)execution.getVariable("age");  
       ruleInput.setSalary(salario.intValue());
       ruleInput.setAge(age.intValue());
       System.out.println("Setting ruleInput " + ruleInput);
       execution.setVariable("ruleInput", ruleInput);
  }
}


rule "salarycheck"
when
    i : RuleInput( employee == "kermit" )
then
    System.out.println("testing");
    RuleOutput o = new RuleOutput();
    o.setResult("rule fired");
    insert(o);
end

I have attached the complete code.
I hope you are able to help me. Best regards,
14 REPLIES 14

ridottiastozze
Champ in-the-making
Champ in-the-making
Hi,
I have solved the problem editing the webapps/activiti-explorer/WEB-INF/applicationContext.xml. I have added the code:

<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration"> 
    <!– Database configurations –>
    <property name="databaseSchemaUpdate" value="true" />
    <property name="jdbcUrl" value="jdbc:h2:tcp://localhost/activiti" />
    <property name="jdbcDriver" value="org.h2.Driver" />
    <property name="jdbcUsername" value="sa" />
    <property name="jdbcPassword" value="" />   
    <property name="jobExecutorActivate" value="true" />
    <property name="dbCycleUsed" value="true" />
    
     <property name="customPostDeployers">
<list>
<bean class="org.activiti.engine.impl.rules.RulesDeployer" />
</list>
      </property>   
  </bean>

best regards,

balu
Champ in-the-making
Champ in-the-making
hi,
I am trying to integrate activiti with drools
i got one sample from activiti forum and followed all the steps correctly
deployed project into activiti explorer its ok, but at the time of starting the process in the explorer its giving the below exception.

pls help me to solve this exception.

com.vaadin.event.ListenerMethod$MethodException: Invocation of method buttonClick in org.activiti.explorer.ui.form.FormPropertiesForm$1 failed.
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:530)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1219)
at com.vaadin.ui.Button.fireClick(Button.java:567)
at com.vaadin.ui.Button.changeVariables(Button.java:223)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.changeVariables(AbstractCommunicationManager.java:1460)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1404)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1329)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:761)
at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:325)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.activiti.explorer.filter.ExplorerFilter.doFilter(ExplorerFilter.java:44)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:724)
Caused by: com.vaadin.event.ListenerMethod$MethodException: Invocation of method componentEvent in org.activiti.explorer.ui.process.ProcessDefinitionDetailPanel$1 failed.
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:530)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1219)
at org.activiti.explorer.ui.form.FormPropertiesForm.access$000(FormPropertiesForm.java:45)
at org.activiti.explorer.ui.form.FormPropertiesForm$1.buttonClick(FormPropertiesForm.java:139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
… 26 more
Caused by: java.lang.NullPointerException
at org.activiti.demo.rules.CreateRuleObjectDelegate.execute(CreateRuleObjectDelegate.java:12)
at org.activiti.engine.impl.delegate.JavaDelegateInvocation.invoke(JavaDelegateInvocation.java:34)
at org.activiti.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:37)
at org.activiti.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:25)
at org.activiti.engine.impl.bpmn.behavior.ServiceTaskJavaDelegateActivityBehavior.execute(ServiceTaskJavaDelegateActivityBehavior.java:49)

thanks in advance.

bestregards,
balu

trademak
Star Contributor
Star Contributor
I really have no idea without any information about what you are doing.

Best regards,

balu
Champ in-the-making
Champ in-the-making
Hai,
I am trying to integrate activiti with drools

I have inserterted the activiti-cfg.jar , drools-api-5.5.0.jar, drools-compiler-5.5.0.Final.jar, drools-core-5.5.0.Final.jar and mvel2-2.1.3.Final.jar , in activiti-5.8\apps\apache-tomcat-6.0.37\webapps\activiti-explorer\WEB-INF\lib,

I have deployed zip file (contains ruleprocess.bpmn and rule.drl files) into activiti explorer successfully,but at the time of starting the process its giving  error "Deployeement xxxx does't contain any rules "

this is my .drl file:
————————
rule "ruleauthentication"
when
    ruleInput : RuleInput( order == "fozzie" )
then
RuleInput ruleinput=new RuleInput();
    System.out.println("testing");
    ruleInput.setOrder("ruleinput");
     
end

this is my .bpmn file:
—————————–
<code>
  <process id="rulestest" name="RuleTest" isExecutable="true">
    <businessRuleTask id="businessruletask1" name="Business rule task" activiti:ruleVariablesInput="${order}" activiti:rules="HelloWorld,secondrule" activiti:resultVariable="ruleoutput"></businessRuleTask>
    <endEvent id="endevent1" name="End"></endEvent>
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="usertask1" name="kermit" activiti:assignee="kermit" activiti:candidateUsers="kermit">
      <extensionElements>
        <activiti:formProperty id="order" name="assign to" type="string" variable="order" required="true"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow3" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="usertask1" targetRef="businessruletask1"></sequenceFlow>
    <userTask id="usertask2" name="fozzie" activiti:assignee="kermit" activiti:candidateUsers="fozzie"></userTask>
    <sequenceFlow id="flow5" sourceRef="usertask2" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow6" sourceRef="businessruletask1" targetRef="usertask2"></sequenceFlow>
  </process>
</code>
please help me to solve this .

thanks in advance.

Best Regards,

balu

balu
Champ in-the-making
Champ in-the-making
here i am getting error see the screen shot.

thanks.

Best Regards,
balu