org.drools.compiler.DroolsParserException while adding Package from DRL
by ssprick
Hello,
let me give you some context at first:
I'm trying to update my drools engine and guvnor from 5.1M1 to 5.3Final.
I exported my existing rules package via Guvnor 5.1 GUI into xml and
imported it back into a fresh Guvnor 5.3. The package content looks fine in
Guvnor and a package binary can be built successfully.
Now something strange happens:
5.1 engine - 5.1 guvnor --> works fine
5.1 engine - 5.3 guvnor --> works fine
5.3 engine - 5.3 guvnor --> fail
(5.3 engine - 5.1 guvnor --> not tested yet)
Let's assume the case "5.3 engine - 5.3 guvnor":
At first all I got was an unexpected global exception -- the globals aren't
added to the rulebase while reading the package. So the system is right
throwing that exception.
But why aren't they added? I figured out that there were millions of errors
while parsing the URL rule package from DRL.
So many errors, that the parser itself gets into an unhandled state and
throws the exception mentioned below.
To mention that:
I retried the same scenario with an empty package, even without any fact
model inserted but got the same error while parsing the package during
creation of a knowledge session.
My questions is:
Why does the old 5.1 engine just do well with the package from the new 5.3
Guvnor while the new 5.3 engine fails?
As I see it, the binary package creation by the guvnor has to be correct
otherwise the old engine would fail too.
I appreciate any help on resolving if there is anything wrong on my side or
if it is a real error in the parser code as the exception intends. Thank
you!
url: http://127.0.0.1:8181/drools-guvnor/rest/packages/defaultPackage/binary
java.lang.IndexOutOfBoundsException: Index: 23, Size: 23
at java.util.ArrayList.RangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at org.antlr.runtime.CommonTokenStream.LT(CommonTokenStream.java:103)
at org.drools.lang.ParserHelper.reportError(ParserHelper.java:386)
at org.drools.lang.DRLParser.compilationUnit(DRLParser.java:182)
at org.drools.compiler.DrlParser.compile(DrlParser.java:225)
at org.drools.compiler.DrlParser.parse(DrlParser.java:136)
at org.drools.compiler.DrlParser.parse(DrlParser.java:141)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:394)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:586)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:37)
at
de.tiq.rules.drools.DrlUrlRuleResource.getKnowledgePackages(DrlUrlRuleResource.java:77)
at
de.tiq.rules.drools.DroolsEngine.createKnowledgeBase(DroolsEngine.java:264)
at de.tiq.rules.drools.DroolsEngine.run(DroolsEngine.java:95)
at de.tiq.rules.TIQRulesEngine.executeRuleResource(TIQRulesEngine.java:178)
at de.tiq.quartz.QuartzTaskExecutor.execute(QuartzTaskExecutor.java:173)
at org.quartz.core.JobRunShell.run(JobRunShell.java:199)
at
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:546)
ERROR JobRunShell - Job TIQRULES_PROJECT4.TIQRULES_PROJECT4 threw an
unhandled Exception:
java.lang.RuntimeException: org.drools.compiler.DroolsParserException:
Unexpected exception raised while parsing. This is a bug. Please contact the
Development team :
Index: 23, Size: 23
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:692)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:37)
at
de.tiq.rules.drools.DrlUrlRuleResource.getKnowledgePackages(DrlUrlRuleResource.java:77)
at
de.tiq.rules.drools.DroolsEngine.createKnowledgeBase(DroolsEngine.java:264)
at de.tiq.rules.drools.DroolsEngine.run(DroolsEngine.java:95)
at de.tiq.rules.TIQRulesEngine.executeRuleResource(TIQRulesEngine.java:178)
at de.tiq.quartz.QuartzTaskExecutor.execute(QuartzTaskExecutor.java:173)
at org.quartz.core.JobRunShell.run(JobRunShell.java:199)
at
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:546)
Caused by: org.drools.compiler.DroolsParserException: Unexpected exception
raised while parsing. This is a bug. Please contact the Development team :
Index: 23, Size: 23
at org.drools.compiler.DrlParser.compile(DrlParser.java:242)
at org.drools.compiler.DrlParser.parse(DrlParser.java:136)
at org.drools.compiler.DrlParser.parse(DrlParser.java:141)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:394)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:586)
... 8 more
ERROR ErrorLogger - Job (TIQRULES_PROJECT4.TIQRULES_PROJECT4 threw an
exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested
exception: java.lang.RuntimeException:
org.drools.compiler.DroolsParserException: Unexpected exception raised while
parsing. This is a bug. Please contact the Development team :
Index: 23, Size: 23]
at org.quartz.core.JobRunShell.run(JobRunShell.java:210)
at
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:546)
Caused by: java.lang.RuntimeException:
org.drools.compiler.DroolsParserException: Unexpected exception raised while
parsing. This is a bug. Please contact the Development team :
Index: 23, Size: 23
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:692)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:37)
at
de.tiq.rules.drools.DrlUrlRuleResource.getKnowledgePackages(DrlUrlRuleResource.java:77)
at
de.tiq.rules.drools.DroolsEngine.createKnowledgeBase(DroolsEngine.java:264)
at de.tiq.rules.drools.DroolsEngine.run(DroolsEngine.java:95)
at de.tiq.rules.TIQRulesEngine.executeRuleResource(TIQRulesEngine.java:178)
at de.tiq.quartz.QuartzTaskExecutor.execute(QuartzTaskExecutor.java:173)
at org.quartz.core.JobRunShell.run(JobRunShell.java:199)
... 1 more
Caused by: org.drools.compiler.DroolsParserException: Unexpected exception
raised while parsing. This is a bug. Please contact the Development team :
Index: 23, Size: 23
at org.drools.compiler.DrlParser.compile(DrlParser.java:242)
at org.drools.compiler.DrlParser.parse(DrlParser.java:136)
at org.drools.compiler.DrlParser.parse(DrlParser.java:141)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:394)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:586)
... 8 more
applicationinstance: de.tiq.web.Application@312737
StatusProcessor: de.tiq.quartz.monitoring.StatusProcessor@1059849
--
View this message in context: http://drools.46999.n3.nabble.com/org-drools-compiler-DroolsParserExcepti...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 1 month
Guvnor cluster problems
by jayadev
One of our business users made changes to a rule package - added an excel
sheet, modified few existing excel sheets, but, his changes are not
reflected on the second server [load balancer took him to server1] On his
screen he can see the total number of excel sheets as 41, but, when I login
[and load balancer took me to server2] I see total number of excel sheets as
40.
So, I added a new excel sheet with that name on server2. Now when business
user tries to pull the list of excel sheets he gets an
"InvocationTargetException" What could be the problem?
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-cluster-problems-tp3528970p35289...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 1 month
multi-factor rule
by Ronald Albury
Hi - I am a Drools newbie and I apologize in advance if the answer to my
question is intuitively obvious to the casual user.
I have an object that has two fields: location(there are more than 50
locations) and age. I am having difficulty building clean rules for the
following pseudo-code
// Rule One
if(location == "A") {
if(age > 60)
do_something();
}
// Rule Two
else if(location == "B") {
if(age > 70)
do_something();
}
// Rule Three
else if(location == "C") {
if(age > 80)
do_something();
}
// Rule Four
else {
if(age > 65)
do_something();
}
The issue comes with Rule Four. How do I avoid writing the rule so that I
don't have to say (location!="A"&&location!="B"&&location!="C") ? I also
don't want to have to write an explicit rule for every possible location.
I considered an activation-group with salience to have the rules executed
in order, but the problem is that if rules 1-3 do not fire, then rule 4
fires for all locations - I can get a hit if location=="C" and age==70.
Is it possible to have a 'Map' and do something like
(age>map.get(location)) ? I could live with creating a map with all
possible locations for key, although I'd rather not go this route.
This problem is typical for the types of rules I'll be writing ... there
can be completely different sets of rule criteria depending on location.
Thanks in advance for your suggestions and your patience.
14 years, 1 month
Multiple Insert and negative rule
by annam2011
Hello,
I'm a newbie to drools.
I would like to know why i get the following output on the console :
Test Message found!!
No strange message :-)
Test Message found!!
Test Message found!!
NotifyEngineTest.java creates 10 events. Rule "test2" should be activated
with every event,
so that the output should look like this:
Test Message found!!
No strange message :-)
Test Message found!!
No strange message :-)
Test Message found!!
No strange message :-)
Could somebody help me with this ?
I appriciate your help
Thanks in advance,
Anna
// NotifyEngineTest.java//
for (int i = 0; i < 10; i++){
Event e = new Event();
e.setId("ID"+Math.random());
e.setTimestamp(new Date());
e.setCatagory("TEST");
e.setMessage( i + " Test");
e.setSystem("localhost");
ruleEngine.insert(e);
_____________________________________________________________________
// RuleEngine.java//
public void insert(Event e) throws RuleEngineException {
FactHandle factHandle = ksession.insert(e);
int numberOfRules = ksession.fireAllRules();
logger.debug("Rules fired: "+numberOfRules);
}
______________________________________________________________________
// Notify.drl//
rule "test"
salience 10
when
$r: Event(message matches ".*Test.*")
then
System.out.println("Test Message found!! "+ $r);
end
rule "test2"
salience 5
when
not ( Event( (system == "anySystem" && catagory == "anyCatagory" ) ||
(system == "anyHost" && message matches ".*Hello.*")))
then
System.out.println(" No strange message :-) ");
end
____________________________________________________________________
--
View this message in context: http://drools.46999.n3.nabble.com/Multiple-Insert-and-negative-rule-tp353...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 1 month
How to use contains with a function
by Hezi Stern
Hi all,
I encountered the following issue:
As an example TaskConectxt() holds a list of time related objects called
times.
I would like to write a rule which ideally would filter the TaskContext
according to a specific time object.
The problematic restriction is that this time object is derived using a
helper function (imported), in this case called getTimeByID which received
as input an enum ID of a time and returns the desired time object.
Ideally the rule would like something like this:
rule "verify time"
when
$tc: TaskContext(times contains
getTimeByID(ETimeID.NOW))
then
//something
end
unfortunately this does not work.
Is there any way to call a function with a param?
Is there a better alternative method than this one?
Thanks,
Hezi
14 years, 1 month
Rules that cumulate on consequence
by lansyj
hi folks
We are working on a requirement that requires us to have multiple rules that
could fire for a given input and for all the rules that fire, we would want
to cumulate the consequence to reach the final consequence.
As an example, if we want to identify the credit score for a person, based
on his gender you might want to assign/increment/decrement the score, then
based on nationality, and so on.
So, considering the long list of such criteria, having rules that cover all
scenarios and are still mutually exclusive isnt a scalable solution. Could
you please advice on how this could be achieved.
We run Drools 5.1.1 and Guvnor; rules are made using the guided editor with
DSLs.
Awaiting your support,
Best Regards
-lj
--
View this message in context: http://drools.46999.n3.nabble.com/Rules-that-cumulate-on-consequence-tp35...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 1 month