Unable to create a new custom accumulate function in BRMS 6.3
Issue
- Developers wrote a custom accumulate function in a Java class and included the jar file as a dependency in a rule definition. The first few lines of the class file are shown below.
package com.example.redhat.rules.customfunctions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
...
public class CustomAccumulate implements org.kie.api.runtime.rule.AccumulateFunction {
...
- In order to use it in a
Guided DSLrule, developer created aDRLfile in the same package as the rule with the following import statement.
import accumulate com.example.redhat.rules.customfunctions.CustomAccumulate newaccumulate
...
However, developer could not get the rule to recognize this custom function until they manually inserted the same import statement into the rule file and saved it in the repository. Eventually, they were able to build the project with the rule. The rule ran correctly and it was working fine. However, when they edit the rule the problem resurfaced. The file still contains the import statement but the rule cannot be validated again. Here is the error message which causes validation error.
Unknown accumulate function: 'newaccumulate' on rule 'TestWithCustomAccumulate'.
All accumulate functions must be registered before building a resource.
How to solve this problem?
Environment
- Red Hat JBoss BRMS (BRMS)
- 6.3.0
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
