cancel
Showing results for 
Search instead for 
Did you mean: 

BusinessRuleTask - deploy error

rdenner
Champ in-the-making
Champ in-the-making
Hi,

I want to use the new BusinessRuleTask element for a test.
I defined a rule (drl) file, which I include in the Business Archive (bar).
I modeled a simple process and two forms. The BusinessRuleTask
executes 2 rules, gets 2 input variables and delivers 1 result variable.

Here is an example of one of my rules:


rule "salarycheck"

when
    (salary > 3000) && (age < 30)
then
    ruleOutput = "pattern1";
end

I wanted to deploy the bar file, but I get the error:
java.lang.NoClassDefFoundError: org/drools/runtime/rule/AgendaFilter

Do I need the Drools package for working with the BusinessRuleTask?
Does anyone have a simple example?

Thanks & Regards,
Rainer.
33 REPLIES 33

rdenner
Champ in-the-making
Champ in-the-making
Hi,

I deployed my bar file now via activiti-probe. The import went fine.

The first thing I noticed in activiti-explorer was the missing BusinessRuleTask element
in the graphical represenation which I called with Show Diagram. But thats no problem.

I started the process, filled out the first form, which is referenced by the start event.
After leaving this form, I get an error:
02080004 Wrapped Exception (with status template): deployment xxxx doesn't contain any rules

I checked the bar file before deployment, there is a drl file with my rules in this package.

Does anyone have an advice?

I also attach my bar file which includes the process, 2 forms and the rule file.
(Bar extension is not allowed, so I renamed the file to zip)

Regards,
Rainer.

trademak
Star Contributor
Star Contributor
Hi,

Thanks for providing the BAR file example.
I'll look into this, this evening.

Best regards,

trademak
Star Contributor
Star Contributor
Hi,

I've noticed a couple of things that you should think about when using the business rule task:

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.
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>

This is missing in the userguide, but needs to be in the activiti-cfg.xml file to get the rules deployed.

3. Make sure you create a valid drl file. It's important to use Javabeans as input variables and output variables.
So maybe you could create a Javabean with salary and age as attributes. The same for the result variable.
4. I saw the bpmn20.xml in your BAR file is inside the diagrams folder. It's better to have it at the root of the BAR file.

With these changes it should work. Let me know if it works for you.

Best regards,

rdenner
Champ in-the-making
Champ in-the-making
Hi,

thanks for your reply and the detailed explanation.

I have only one question for understanding. I have to use Javabeans to map the processvariables to drools.
But how do the Javabeans get the processvariables? Do I have to make a Delegate for input and output variables to
initialize the Javabeans? The Delegate could be created with a Service Task or as a Listener.

Regards,
Rainer.

trademak
Star Contributor
Star Contributor
Hi,

Right, a simple way to do this is to create a java service task before the business rule task is invoked to set the process variables in the java bean and store the java bean as a new process variable. Then the output of the ruleset should also be a javabean.

Best regards,

rdenner
Champ in-the-making
Champ in-the-making
Hi,

thanks for your affirmation. I will test this solution and give you feedback.

Regards,
Rainer.

rdenner
Champ in-the-making
Champ in-the-making
Hi,

I made two beans for input and output variables. I also made a delegate for
creating the beans. But I think my rule never gets fired. I made several tests
but without success.

I attached my small eclipse test project. Perhaps you can see where I made an error.

Thanks,
Rainer.

trademak
Star Contributor
Star Contributor
Hi,

I made a couple of changes and now it works. You can find the project (using the Activiti Designer) attached.
The changes include:

1. input variable should be ${ruleInput}
2. drl file is changed
3. I've added another service task to get the right output variable.

Best regards,

rdenner
Champ in-the-making
Champ in-the-making
Hi,

thanks for your effort.
It works all now.

Regards,
Rainer.