Unable to create a new custom accumulate function in BRMS 6.3

Solution Unverified - Updated -

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 DSL rule, developer created a DRL file 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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content