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

  • Home
  • SEARCH
  • 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 126605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:20:39+00:00 2026-05-11T05:20:39+00:00

I’m using Drools (for the first time) to express some rules and it has

  • 0

I’m using Drools (for the first time) to express some rules and it has been working really well so far. However I’ve been given a new condition that I’m not able to express in the rules language very clearly.

Essentially I need to perform an action on the players account if they have an outstanding balance on there account between a certain amount, where they haven’t made a payment in the last week and where they haven’t made a payment in the last 4 weeks that is greater than or equal to a weekly deduction. There are a few other rules but I’ve removed them in an effort to simplify the rule for this question. It’s the last rule that is causing me a problem.

rule 'The broken rule'    salience 10    no-loop    when       Player( $playerNumber : playerNumber )       $a : Account( // balance between £5 and £100 and no arrangement        playerNumber == $playerNumber &&          accountBalanceInPence >= 500 &&          accountBalanceInPence <= 10000       )       not ( // no payment in last week          exists AccountTransaction(             playerNumber == $playerNumber &&             transactionDate >= oneWeekAgo &&             transactionCode == 'P' // payment          )       )       /* It's this next bit that is broken */       not ( // no payment > (weekly cost * 4) paid within last 4 weeks          $deduction : AccountTransaction( // a recent transaction             playerNumber == $playerNumber &&             transactionDate >= fourWeeksAgo &&             transactionCode == 'D' // deduction          )          exists AccountTransaction( // the payment             playerNumber == $playerNumber &&             transactionDate >= fourWeeksAgo &&             transactionCode == 'P' // payment             amountInPence >= ($deduction->amountInPence * 4)          )    )    then       // do some action to the account end 

The problem is that it just doesn’t work, I keep getting org.drools.rule.InvalidRulePackage exceptions thrown. I was just guessing on the syntax but couldn’t seem to find an example that showed what I’m trying to do. Is it even possible?


The full original error message is:

'unknown:50:3 mismatched token: [@255,1690:1695='exists',<39>,50:3]; expecting type RIGHT_PAREN[54,4]: unknown:54:4 mismatched token: [@284,1840:1852='amountInPence',<7>,54:4]; expecting type RIGHT_PAREN[54,22]: unknown:54:22 Unexpected token '$payment'' 

After trying the suggestion in the first comment the error is:

'[50,3]: unknown:50:3 mismatched token: [@255,1690:1695='exists',<39>,50:3]; expecting type RIGHT_PAREN[54,4]: unknown:54:4 mismatched token: [@284,1840:1852='amountInPence',<7>,54:4]; expecting type RIGHT_PAREN[54,45]: unknown:54:45 mismatched token: [@293,1881:1881='*',<71>,54:45]; expecting type LEFT_PAREN[55,3]: unknown:55:3 mismatched token: [@298,1890:1890=')',<12>,55:3]; expecting type THEN' 
  • 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. 2026-05-11T05:20:40+00:00Added an answer on May 11, 2026 at 5:20 am

    yes as you guessed, you need to put an explicit ‘and’ inside the ‘not’ pattern to join them together.

    The only time you don’t need the ‘and’ is at the top level:

    eg

    when Foo() Bar() 

    Doesn’t require a an ‘and’

    but this is implicitly the same as

    when Foo() and Bar() 

    So your solution seems correct. The lack of a top level ‘and’ seems to be convention in most rule languages (going back to CLIPS !)

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have some data like this: 1 2 3 4 5 9 2 6
In order to apply a triggered animation to all ToolTip s in my app,
I want use html5's new tag to play a wav file (currently only supported

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.