How to dump the class/src generated by .drl file?
by Yang Song
Greetings everyone,
Does anyone know how to dump the class generated from .drl file to disk? Or
even better if the generated Java source file can be dumped?
Looking for some hints here, I got a NPE when firing the rules. However, it
is really hard to find out why the NEP was thrown... If I can have the
dumped class file, then I can be disassemble it back to Java code.
To debug this rule in Eclipse is a bit difficult here, because the
project is a little "big" and we usually use logging to do debugging...
java.lang.NullPointerException
at monitor.Rule_ftp_other_host_alarm_0.consequence
(Rule_ftp_other_host_alarm_0.java:23)
at monitor.Rule_ftp_other_host_alarm_0ConsequenceInvoker.evaluate
(Rule_ftp_other_host_alarm_0ConsequenceInvoker.java:26)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java
:545)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java
:509)
at org.drools.common.AbstractWorkingMemory.fireAllRules(
AbstractWorkingMemory.java:430)
at org.drools.common.AbstractWorkingMemory.fireAllRules(
AbstractWorkingMemory.java:392)
at com.monitor.ruleengine.InferenceMachine.fireAllRules(
InferenceMachine.java:400)
at com.monitor.ruleengine.InferenceMachine.run(InferenceMachine.java
:314)
at java.lang.Thread.run(Thread.java:595)
Thanks very much,
Yang
17 years, 3 months
problems with Otherwise()
by Matt Geis
I've got the following three rules in my DRL, but I'm seeing odd results.
rule "matchfound"
when
s : String()
then
System.out.println("got a match, string found in working memory");
end
rule "intmatchfound"
when
i : Integer()
then
System.out.println("got a match, Integer found in working memory");
end
rule "no matching rule"
when
Otherwise()
then
System.out.println("no rule applied, using otherwise rule");
end
If I assert a String, then the 'matchfound' rule fires. If I assert an Integer, 'intmatchfound' fires. If I assert an object of a different type or do not assert anything, the rule I would expect to fire ('no matching rule') never fires. The only way I can get it to fire is if I explicitly assert an instance of Otherwise.
I was under the impression that Drools would automatically assert it when it sees that no other rule has fired.
Am I doing something wrong here? Did usage of Otherwise change?
____________________________________________________________________________________
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more.
http://mobile.yahoo.com/go?refer=1GNXIC
17 years, 3 months
Guided editor (BRL) rules in the drools-examples-brms dont work
by Edgardo
Hi list, I post my problem in the rules-dev list. The problem is execute
the "Driver is Crazy", "Driver is too old" and "Driver special age
Approved" rules. I have the problem of the next section:
> Edgardo wrote:
>> Yes, I did it, in the package configuration. I use the
>> drools-4.0.0-brms version. The problem is at the moment to evaluate the
>> next generate code of the rule:
>>
>> then
>> Rejection fact0 = new Rejection();
>> fact0.setReason( "Driver too old" );
>> insert( fact0 );
>>
>> If I use the Technical rule text editor, i dont have any problem.
>>
>> Greetings from Chile :)
>>
>> En Fri, 03 Aug 2007 19:06:05 -0400, Mark Proctor
>> <mproctor(a)codehaus.org> escribió:
>>
>>> did you upload your model and import it?
>>>
>>> Mark
>>> Edgardo wrote:
>>>> Hi rules-dev list, (my english is very poor, sorry) I am interested
>>>> in using the
>>>> BRMS of JBoss Rules, but when I use the guided editor, this rules dont
>>>> work, and in drools-examples-brms example, this dont work too, the
>>>> error message (in the
>>>> "Driver is Crazy" rule)is:
>>>>
>>>> RuleAgent(insuranceconfig) INFO (Fri Aug 03 16:05:58 CLT 2007): Adding
>>>> package called org.acme.insurance
>>>> org.mvel.CompileException: class or class reference not found:
>>>> Rejection()
>>>> at
>>>> org.mvel.optimizers.impl.asm.ASMAccessorOptimizer.optimizeObjectCreation(ASMAccessorOptimizer.java:1771)
>>>> at
>>>> org.mvel.ast.NewObjectNode.getReducedValueAccelerated(NewObjectNode.java:49)
>>>> at org.mvel.MVELRuntime.execute(MVELRuntime.java:87)
>>>> at
>>>> org.mvel.CompiledExpression.getValue(CompiledExpression.java:98)
>>>> at
>>>> org.mvel.CompiledExpression.getValue(CompiledExpression.java:93)
>>>> at
>>>> org.mvel.ast.TypedVarNode.getReducedValueAccelerated(TypedVarNode.java:36)
>>>> at org.mvel.MVELRuntime.execute(MVELRuntime.java:87)
>>>> at
>>>> org.mvel.CompiledExpression.getValue(CompiledExpression.java:98)
>>>> at org.mvel.MVEL.executeExpression(MVEL.java:202)
>>>> at
>>>> org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:32)
>>>> at
>>>> org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:545)
>>>> at
>>>> org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:509)
>>>> at
>>>> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:430)
>>>> at
>>>> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:392)
>>>> at
>>>> org.acme.insurance.launcher.InsuranceBusiness.testDriverCrazy(InsuranceBusiness.java:93)
>>>> at
>>>> org.acme.insurance.launcher.InsuranceBusiness.executeExample(InsuranceBusiness.java:19)
>>>> at org.acme.insurance.launcher.MainClass.main(MainClass.java:13)
>>>> org.drools.spi.ConsequenceException: org.mvel.CompileException: class
>>>> or
>>>> class reference not found: Rejection()
>>>> at
>>>> org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:549)
>>>> at
>>>> org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:509)
>>>> at
>>>> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:430)
>>>> at
>>>> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:392)
>>>> at
>>>> org.acme.insurance.launcher.InsuranceBusiness.testDriverCrazy(InsuranceBusiness.java:93)
>>>> at
>>>> org.acme.insurance.launcher.InsuranceBusiness.executeExample(InsuranceBusiness.java:19)
>>>> at org.acme.insurance.launcher.MainClass.main(MainClass.java:13)
>>>> Caused by: org.mvel.CompileException: class or class reference not
>>>> found:
>>>> Rejection()
>>>> at
>>>> org.mvel.optimizers.impl.asm.ASMAccessorOptimizer.optimizeObjectCreation(ASMAccessorOptimizer.java:1771)
>>>> at
>>>> org.mvel.ast.NewObjectNode.getReducedValueAccelerated(NewObjectNode.java:49)
>>>> at org.mvel.MVELRuntime.execute(MVELRuntime.java:87)
>>>> at
>>>> org.mvel.CompiledExpression.getValue(CompiledExpression.java:98)
>>>> at
>>>> org.mvel.CompiledExpression.getValue(CompiledExpression.java:93)
>>>> at
>>>> org.mvel.ast.TypedVarNode.getReducedValueAccelerated(TypedVarNode.java:36)
>>>> at org.mvel.MVELRuntime.execute(MVELRuntime.java:87)
>>>> at
>>>> org.mvel.CompiledExpression.getValue(CompiledExpression.java:98)
>>>> at org.mvel.MVEL.executeExpression(MVEL.java:202)
>>>> at
>>>> org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:32)
>>>> at
>>>> org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:545)
>>>> ... 6 more
>>>>
>>>> Thanks :), I am waiting for you response...
>>>>
>>>
>>> _______________________________________________
>>> rules-dev mailing list
>>> rules-dev(a)lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>
>>
>>
>
> _______________________________________________
> rules-dev mailing list
> rules-dev(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
--
Edgardo Ibañez O.
17 years, 3 months
finding matching entries in parallel arrays
by Aaron Dixon
My problem boils down to finding matching entries in parallel arrays.
Here is a rule that succesfully does just that:
rule "Find matching entry in parallel arrays"
when
$first : ArrayList( )
$second : ArrayList( this != $first )
$i : Integer( this < $first.size )
eval( $first.get($i) == $second.get($i) )
then
System.out.println ( "Found match at index " + $i + "!" );
end
To execute this rule, I must insert (assert) the two ArrayList facts as well
as at least as many Integer facts as there are items in the ArrayLists.
What I don't like about this rule is that
(1) I have to assert the Integers
(2) I can't support arbitrarily-sized lists in my rules (without
asserting that many Integer facts)
So -- Is there a better way?
What if a future version of Drools supported implicit Number facts that
allowed for these kinds of indexing rules?
Aaron
17 years, 3 months
problems using the from
by hypnosat7
Hi,
This is my rule :
#declare any global variables here
global MockServiceRepository service
rule "Your First Rule"
when
Variable($list : values ) from service.findVariableByName("njdn","dedkm")
r : Rum(diagnostic memberOf (value in $list))
then
System.out.println("test From ok");
end
And this is the errors
testFromPackage/Rule_Your_First_Rule_0.java (12:581) : value cannot be
resolved
testFromPackage/Rule_Your_First_Rule_0.java (12:587) : Syntax error on
token "in", instanceof expected
testFromPackage/Rule_Your_First_Rule_0.java (12:590) : $list cannot be
resolved to a type
I have a class Variable with a values property :
private Set<VariableValue> values = new LinkedHashSet<VariableValue>();
And a class VariableValue with those properties :
private String id;
protected String value;
private Variable variable;
--
View this message in context: http://www.nabble.com/problems-using-the-from-tf4229482.html#a12032198
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 3 months
WG: Second Rule does not recognize changes from first rule?
by Martin Book
Hello,
i am a newbie at JBoss Rules and have a problem with a ruleset. Here are my
rules:
rule "1.CallsPerDay" --> Modifies the "CallsPerDayOfWeek" objects.
salience 35
when
$dayObj: CallsPerDay( $day: dayOfWeekS != null, $calls:calls > 0
)
$dayInWeek: CallsPerDayOfWeek( day == $day )
then
$dayInWeek.addCalls($calls); --> Changes call variable.
System.out.println("Drools: "+$dayObj.getInfo()+" /
"+$dayInWeek.getCalls());
End
//Output: Drools: On Mo 02/19/2007 12:00:00 AM 97 calls came in. / 104
rule "2.ProcessAgents" -> Should only process on changed "CallsPerDayOfWeek"
objects (calls must be 104 but seem to be still 0)
salience 35
when
$dayInWeek:CallsPerDayOfWeek ($callsTMP: calls==0, sum == 0)
then
System.out.println("Sum = "+$dayInWeek.getSum()+" for
"+$dayInWeek.getDay()+" CallTMP: "+$callsTMP+" /CallReally:
"+$dayInWeek.getCalls());
end
//Output= Sum = 2 for Mo CallTMP: 0 /CallReally: 104
Why is the "calls" variable still 0 at the beginning of rule
"2.ProcessAgents", although it was modified by the rule "1.CallsPerDay"?
with kind regards
Martin
17 years, 3 months
Drools Puzzle #1: Ages of the sons
by Ellen Zhao
Hallo all!
I talked about running a periodic puzzle solving contest in the user
mailing list to some people in the drools team. They have never done
it before so did not know how this contest will come out. However, I
was allowed to make the first try. If no body is interested, there
won't be any Drools Puzzle #2. Sorry for the spam if you do not like
this at all. In the end of this email you can see how I came up with
this idea.
So, here is the puzzle for round No. 1:
------------------------------------------------------------------------------------------------------------------------------------
Difficulty level: settler
An old man asked a mathematician to guess the ages of his three sons.
Old man said: "The product of their ages is 36."
Mathematician said: "I need more information."
Old man said:"Over there you can see a building. The sum of their ages
equals the number of the windows in that building."
After a short while the mathematician said: "I need more information."
Old man said: "The oldest son has blue eyes."
Mathematician said: "I got it."
------------------------------------------------------------------------------------------------------------------------------------
This is a simple puzzle, you may not need any computer to solve it.
But here are the rules:
1. Solution (the core algorithm) must be written in drools. Any
dialect is allowed. Any DSL is allowed.
2. Any kind of user interface is allowed.
3. Make your program as easy to test as possible. Please attach a
simple and short readme file about how to build/test/deploy it.
4. The drools team will measure the performance of all submissions on
a same computer.
3. The winner will be allowed to post the next puzzle.
4. Any participator, no matter finally win or not, will get points for
each participation. Drools team will run a global ranking system and
build a hall of fame for all participators. At the end of the year,
the one who has most points will be awarded with ( Drools team please
fill here, something like a T-shirt or ?). Top ten people in the hall
of fame will be awarded with (Drools team please fill here).
5. If there are many, many participators, the Drools team might
consider things like "shortest run-time award", "least memory-usage
award", "best UI award", "shortest code award", etc. for each puzzle.
6. Currently the puzzle will come once half month. Submission deadline
of this round is August 15th, 2007.
7. Please do not post your solution to the user mailing list, since
everybody can see your program before the deadline. Drools team please
specify an email account to which participators can post solutions.
8. Best/inspiring solutions will be disclosed when next round is on.
9. If any Drools bug is caught during your solving of the puzzle, the
Drools team will award you with (Drools team please fill here).
-----------------------------------------------------------------------------------------------------------------------------------
Any constructive advice and suggestion about the rules of Drools
Puzzle is welcome.
Here is guideline for posting puzzles:
1. You do not want to scare people away with too difficult puzzles or
bore people with questions like 1+1=?, so please consider a proper
difficulty level for the puzzle.
2. NP-complete or NP-hard is okay. For some NP-hard problems,
sub-optimal solutions can be achieved efficiently. But do please tag
the difficulty level as something like "veteran", "guru", etc.
3. Complexity aside, there is still scope and testability
consideration. Puzzles like "How to integrate my 15 different kind of
services objects and my entity home with Drools?" might be
algorithmically not difficult, but the application-building can really
take a lot of time and energy, and it is not straightforward to test
the solution.
4. The purposes of this contest are:
4.1 To learn from each other, enhance our programming skill and
learn good algorithms, good implementations.
4.2 To encourage people to explore features of Drools.
4.3 For fun.
So your puzzle should not take too much work to solve. It should not
mentally or physically torture participators.
---------------------------------------------------------------------------------------------------------------------------------
This idea was inspired by a "Weekly Challenge" running on dpreview.com
user forum and GOTM from http://gotm.civfanatics.net/
On dpreview.com, a subject is posted by the winner of the prior week,
people can post their photos to compete. On civfanatics.net, an
initial configuration file is posted each month, and gamers submit
their end results for ranking. Both of these two non-official contests
are running very well, I hope Drools Puzzle will turn out a fun thing
too.
Regards and nice weekend,
Ellen
17 years, 3 months