AnsweredAssumed Answered

Integrate Activiti with Drools

Question asked by ridottiastozze on Jan 19, 2012
Latest reply on Oct 25, 2013 by balu
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,

Attachments

Outcomes