ClassCastException
by Christoph Kramer
Hi all,
i've some problems with a ClassCastException when using the
"or"-conditional element.
I have different Java-Beans which all have some string-values. Now I
want to create one rule which is able to handle every type of my classes
because it would be a lot of work to create one rule for every class.
Depending on the type of beans in the working memory the programm is
crashing with an ClassCastException.
Here is a snippet of my drl-file with the "crashing-rule":
rule "BizLocation"
when
$epc : EPC()
QuantityEventType(epcClass == $epc.value ,$bizLoc: bizLocation
!=null ) or AggregationEventType(childEPCs.epc contains $epc, $bizLoc :
bizLocation != null) or ObjectEventType(epcList.epc contains $epc,
$bizLoc : bizLocation != null)
then
System.out.println("BizLocation: " +$bizLoc.getId());
end
There are some EPC's in the working memory and some Events (which might
be of type QuantityEventType, AggregationEventType or ObjectEventType).
When there are only ObjectEventType in the working memory, everything
works fine, but wenn there is an QuantityEventType this rule crashes
with "org.fosstrak.epcis.model.QuantityEventType cannot be cast to
org.fosstrak.epcis.model.ObjectEventType".
I've lot of other, similar rules some of them crashing, others don't.
Can anyone give me a hint where is the error?
Thanks,
Christoph
PS: Sorry for the bad english :(
16 years, 10 months
Guvnor to build rules for Drools Fusion
by cyphr
Hi,
I've been looking into Drools for a couple of weeks now - with more serious
attention to Drools fusion.
There are some things am not able to gauge accurately, please help me out
here.Drools Fusion appears to be able to handle what i want.
The challenge is to have an end user (read Business User , Completely
Non-Technical Folk) interface to make these complex rules from a webpage. Am
not able to clearly assert if Guvnor will be able to craft CEP oriented
queries from the UI, and will it be possible for completely non techie
person to do that too...
a. Can this be achieved - build rules (free form, not template based)
without Technical know how ( of Drools or CEP).
b. Can Guvnor be used to achieve this ?
The UI should be capable of making rules that -
1. Correlate different types of events across different time windows.
2. Certain rules might need caching and storing of the facts for a longer
period of time.
3. Slightly complex rules which can correlates values inferred from other
rules over various time windows again AND specify a series of actions that
need to be done if the condition is matched - like storing those inferred(or
accumulated) values into a database or sending out an email.
I am seeking inputs to these two questions - can someone throw some light
here?
Thanks in anticipation.
Regards,
Rishi
PS: Thanks to Edson for the trunk docs - wonderfully written for any newbie
to jump right in (cant wait to see the rest, though).
--
View this message in context: http://www.nabble.com/Guvnor-to-build-rules--for-Drools-Fusion-tp23553352...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 10 months
Lists and enums in Drools
by Armaghan Mahmud
Hi,
I need help with constructing rules for my scenario.
I started off by creating enum values in the main java file and comparing
them with the rules to get different responses for different enum values.
That was easy.
This time, I'm constructing a list of enum values and passing them into the
rules engine as well. I would like to configure my rules in such a way that
when they look for the different enum values, they should also look in the
list to test if the enum value passed into the rules engine is a member of
the list or not. My old rules looked like this:
rule "Testing for Alpha"
salience 100
when
alpha : AlphaWrapperClass(type == Class.ALPHA)
then
System.out.println("Found Alpha");
alpha.isFound(true);
end
I tweaked the above rule to :
rule "Testing for Alpha"
salience 100
when
$test: AlphaEnumCollectionsWrapperClass(alphaList : alphaList)
alpha : AlphaWrapperClass(type == Class.ALPHA && $test contains type )
then
System.out.println("Found Loudspeaker Equipment. Who wants to jam that?
Must resist... Jamming sequence in progress... ");
materiel.setJam(true);
end
But I'm seeing the following error:
org.drools.rule.InvalidRulePackage: Unable to create Field Extractor for
'$test' of '[ClassObjectType classAlphaEnumCollectionsWrapperClass]' in rule
"Testing for Alpha": [Rule name=Testing for Alpha, agendaGroup=MAIN,
salience=100, no-loop=false]
I'd greatly appreciate your help.
Thanks,
Armaghan
16 years, 10 months
NullPointerException with Wrapper objects
by dhai
I am facing problems which many have encountered in the past. I searched
forums but could not get precise answer. The problem is with null values in
Wrapper objects. See the following code:
rule "Null Check " salience 100
when
Salary ( ld : loanDeduction==null || < 0f ) // loanDeduction
is java.lang.Float
then
log("Load return is null"); //Global function
ld = 0f;
end
rule "Nett Salary" salience 70
when
Salary ( nett != ( gross – loanDeduction – pf) )
then
log("Invalid nett salary amount");
end
You may have idea what I am trying to do. But I get NullPointerException in
“Nett Salary” rule when I fire the rules having fact with null in the
loanDeduction attribute. I believe my “Null Check” exception should execute
first and it does when I put negative value in loadDeduction. What is
solution in such a case?
--
View this message in context: http://www.nabble.com/NullPointerException-with-Wrapper-objects-tp2351550...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 10 months
when will drools guvnor support the drools rule template(drt)?
by Tao Yang
hi, all
we use the drools rule template and decision table in our project
development, and we want to use drools guvnor to manage those templates and
tables but we find the drools guvnor don't support the drools rule
templat(drt). who can tell me when drools guvnor supporting the drools
rule template(drt)? thanks a lots.
best regards
Chris
2009.5.13
16 years, 10 months
KnowledgeAgent and Pipeline
by David Zeigler
Hi,
I've set up the KnowledgeAgent to automatically reload the rules
resources if they change. If I use this with a Pipeline, it seems
that its StatelessKnowledgeSession is not reloaded automatically. The
only way I've been able to get the Pipeline to reflect the rules
change is to do the following prior to each pipeline.insert():
StatelessKnowledgeSession ksession =
kagent.getKnowledgeBase().newStatelessKnowledgeSession();
Pipeline pipeline =
PipelineFactory.newStatelessKnowledgeSessionPipeline(ksession);
pipeline.setReceiver( messageTransformer );
Reloading the pipeline for each request adds a lot of overhead (halves
my transactions per second). Is there a way to automatically reload
the Pipeline's session when its needed instead of recreating the
Pipeline prior to each insert? I see there is a
ResourceChangeListener interface that I could probably use to
accomplish this, but I figured I'd ask in case there is a better way
to handle this case with pipelines. What's the best approach?
I'm using 5.0.0.CR1.
Thanks!
David
16 years, 10 months
Drools Flow Trigger process by ruleset
by Garrett Conaty
I've seen in the latest docs on trunk that it's possible to set some
constraints on a start node so that a process would execute when the
appropriate rules matched.
However I can't see an example of this, nor can I edit the properties
through the Eclipse UI.
Is it possible to define a condition under which the process will
execute and then have the process start when the rule matches. Is
this done external to the rule file or can it be done on the rulefile
itself? I could see a few ways of doing this and am looking for some
guidance towards the correct (read as easiest for biz users) method.
1) Kick off a process that the first node after the start is a
ruleflow group (serving basically as a gate)
2) Deploy a rule that when it matches starts up the process (separate
rule file and separate ruleflow file)
3) Define a start condition in the rule file and deploy the process.
Then whenever the rule matches, a process instance is started.
Personally I like #3 and the docs seem to imply it's possible, but I
can't see how.
Thanks,
Garrett
16 years, 10 months
Using groovy classes as Fact Classes in Guvnor
by leesy84
Hi
I am currently trying to implement Drools 5.0.CR1 with grails, I have
created a couple of domain classes which are simple Groovy classes with a
couple of fields. I want to load these classes as my model into Guvnor and
then create rules using those classes. I am having a few problems when
"Saving and Validating" my configuration. I have a war file that is
generated using maven and it has my classes files inside it in
/WEB-INF/classes/ . I load the war as my model and the classes are shown on
the packages main page but the following error is given when pressing "Save
and Validate configuration"
[ERR 102] Line 1:10 mismatched input '-'
I have also tried using groovyc to compile my class files then jar'ing them
up and loading that as the model but got another error:-
java.lang.ClassNotFoundException: groovy.lang.GroovyObject
I was wondering if it is possible to use groovy compiled class files and if
it is then does anyone know what my issue might be or how it is meant to be
done correctly.
Thanks in advance for any help
Daniel Lees
--
View this message in context: http://www.nabble.com/Using-groovy-classes-as-Fact-Classes-in-Guvnor-tp23...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 10 months