Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6318445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:38:20+00:00 2026-05-24T15:38:20+00:00

The short version : How do I get JBPM5 Rule Nodes to use a

  • 0

The short version: How do I get JBPM5 Rule Nodes to use a DRL file which reads and updates process variables?

The long version:
I have a process definition, being run under JBPM5. The start of this process looks something like this:

[Start] —> [Rule Node] —> [Gateway (Diverge)] … etc

The gateway uses constraints on a variable named ‘isValid’.

My Rule Node is pointing to the RuleFlowGroup ‘validate’, which contains only one rule:

rule "Example validation rule"
    ruleflow-group "validate"

    when
        processInstance : WorkflowProcessInstance()
    then
        processInstance.setVariable("isValid", new Boolean(false));
end

So, by my logic, if this is getting correctly processed then the gateway should always follow the “false” path.

In my Java code, I have something like the following:

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("myProcess.bpmn"), ResourceType.BPMN2);
kbuilder.add(ResourceFactory.newClassPathResource("myRules.drl"), ResourceType.DRL);

KnowledgeBase            kbase    = kbuilder.newKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

new Thread(new Runnable()
   {
      public void run()
      {
         ksession.fireUntilHalt();
      }
   }).start();

// start a new process instance
Map<String, Object> params = new HashMap<String, Object>();
params.put("isValid", true);
ksession.startProcess("test.processesdefinition.myProcess", params);

I can confirm the following:

  • The drl file is getting loaded into working memory, because when I put syntax errors in the file then I get errors.
  • If I include a value for “isValid” in the Java params map, the process only ever follows the path specified by Java, apparently ignoring the drools rule.
  • If I take the “isValid” parameter out of the params map, I get a runtime error.

From this I assume that the final “setVariable” line in the rule is either not executing, or is updating the wrong thing.

I think my issue is related to this statement in the official documentation:

Rule constraints do not have direct access to variables defined inside the process. It is
however possible to refer to the current process instance inside a rule constraint, by adding
the process instance to the Working Memory and matching for the process instance in your
rule constraint. We have added special logic to make sure that a variable processInstance of
type WorkflowProcessInstance will only match to the current process instance and not to other
process instances in the Working Memory. Note that you are however responsible yourself to
insert the process instance into the session and, possibly, to update it, for example, using Java
code or an on-entry or on-exit or explicit action in your process.

However I cannot figure out how to do what is described here. How do I add the process instance into working memory in a way that would make it accessible to this first Rule Node? Rule Nodes do not seem to support on-entry behaviors, and I can’t add it to the Java code because the process could very easily complete execution of the rules node before the working memory has been updated to include the process.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T15:38:20+00:00Added an answer on May 24, 2026 at 3:38 pm

    As you mentioned, there are several options to inserting the process instance into the working memory:
    – inserting it after calling startProcess()
    – using an action script to insert it (using “insert(kcontext.getProcessInstance()”)

    If calling startProcess() might already have gone over the rule task (which is probably the case in your example), and you don’t have another node in front of your rule task where you could just use an on-entry/exit script to do this (so that’s is hidden), I would recommend using an explicit script task before your rule task to do this.

    Kris

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

short version: how can I get rid of the multiple-versions-of-python nightmare ? long version:
Short version: I have a similar setup to StackOverflow. Users get Achievements. I have
Short version: assuming I don't want to keep the data for long, how do
Short Version: When I've created a Channel using ChannelFactory on a client which uses
Short version: How can I get the URL of the server my MVC3 project
Short version: For a cache class I need to get notified if an object
Short version: How can I get a regex that matches a@a.aaaa but not a@a.aaaaa
Short version: Is there a simple way to get the value of a primary
The short version is that I have a protocol which has an optional parameter.
The short version: I try to compile MAGMA and get complains about missing symbols:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.