Rule Validation/Package Build Error in Guvnor: Class Not Found
by Ike Okafo
Hello,
I am new to Drools and have written a rule .DRL file which contains some
helper function imports from other packages, fact objects imports from
other packages and the rules that act on these facts. The file works well
when I call it from my javacode using the rulebase or knowledgebase
approach.
The drl file itself is in its own package.
I now have a requirement to call the same rules from within Guvnor.
The goal is to enable business users modify these rules through the
Guvnor UI and also take advantage of the disable individual rules
feature within guvnor.
My current difficulty is importing and validating the rules in guvnor,
along with the associated fact jar files and finally interfacing
with guvnor from my code. Any help would be appreciated .
The main error happens when I try to build a binary package and create
a snapshot of the working rule file I imported for deployment.
When I hit the save and validate configuration button, I get
*"class not found"* validation errors for all the classes imported at
the top of the rule file - includingng the helper import functions
and facts used in the rules. Same thing happens when I try to
build the package I get the following errors
"Error importing: <list of all classes in import statement in rule file>"
Here are the steps I followed in importing the rule file and Jar file
containing the classes
into Guvnor
(1) First within Guvnor I created a package corresponding to the package
path
for for each of the jar files whose classes are referenced/imported in the
rule .DRL file
(2) I created the jar files for each of these packages in eclipse
(3) Imported those jars individually into each of the packages created in
guvnor
using upload model jar function and selecting the appropriate path as
created in step 1 2 above
(4) Imported the rule file which is in its own package - using the create
package (upload method)
(5) I then try to save and validate the imported rule file in step 5 (this
is where the error occurs)
I have already setup my code to call guvnor as follows
RuleAgent agent = RuleAgent.newRuleAgent("guvnor.properties");
RuleBase masterRuleBase = agent.getRuleBase();
guvnor.properties contains only one entry
url =
http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/Some...
It is my understanding that after I import the rule file
I need to save and validate and build the package
in order to point the url to the path above. If I point the url to just
the drl file itself will it work?
i.e url=
http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/Some...
Any help to resolve the class not found error will
be much appreciated
Thanks
15 years, 5 months
Time to Scale some Drools
by tolitius
1. What are the options to scale?
If many rule requests are coming from different nodes ( server nodes ) OR
many rule requests are coming from the same node, but with a very high
frequency: WHAT ARE THE BEST PRACTICE(S) to:
Create
Expose
Access
All the knowledge artifacts? ( KnowledgeBase, Session, etc... )
Guvnor is not production ready, hence I am looking for ways / best practices
with production ready components.
2. I understand that "session creation is very light", but how light? We
have certain SLAs in milliseconds for the whole "request / response" travel,
which would include throwing facts into the engine and getting results.
3. Seems like caching a KnowlegeBase ( e.g. GemFire, Terracotta, etc.. )
across nodes would be one way to go, what are others?
Thank you,
/Anatoly
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Time-to-Scale-some-Dr...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 5 months
Query on loading facts dynamically
by jobin wilson
Hello List,
I have a very basic question about inserting facts into the working memory
dynamically.For firing the rules,we should be having all our facts in the
working memory.In that case,How will we deal with the situation where the
facts that we need for evaluation of a particular rule is dependent on the
rule itself (needs to be brought it dynamically)?
Say for example say i want to use rule engine to reward all students with
average scores for all subjects > 75 for the past 3 exams.
The facts that i have are the Student objects & their Subject wise
scores(one to many relation;one student to many exams & each exams having
many subjects).
I want the "when" condition to be satisfied for all students whose average
scores for all subjects for the past 3 exams to be greater than 75
and the consequence to be to just print out the name of the student.
In this case,should i be loading all the student objects & each of their
past exam scores in the whole system to find student objects satisfying this
critera?
Since i already know that the rule just need the average scores for just the
past 3 exams for each student,wouldn't loading the whole facts be
inefficient?
Is there a way in which i can specify somehow how much of the facts needs to
be loaded before firing the rule based on the rule itself?
i mean a rule which is aware of the quantity of the facts on which it needs
to work on(considering loading 3 facts versus 100 facts)?
Thanks a lot in advance for all your inputs and suggestions on this.
Thanks & Regards
Jobin Wilson
15 years, 5 months
Rule Compilation Problems
by Jean-Philippe Steinmetz
Hello everyone,
I'm fairly new to Drools, having only worked with a basic setup for a
little while now. I've successfully gotten a Drools 5.0.1 runtime
working with an app running under JBoss 5 but now I need Drools to run
under a standalone application. I've more or less copied all of the set
up that I used in the JBoss app but am experiencing weird compilation
problems.
My application code looks like the following...
KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent("MyAgenda");
kagent.applyChangeSet(ResourceFactory.newClassPathResource("my_rules.xml
"));
KnowledgeBase kbase = kagent.getKnowledgeBase();
final StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
ksession.addEventListener(new DebugAgendaEventListener());
ksession.addEventListener(new DebugWorkingMemoryEventListener());
KnowledgeRuntimeLogger krlogger =
KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);
ksession.insert(myObject);
ksession.fireAllRules();
krlogger.close();
ksession.dispose();
and my rules file looks like...
package mypackage
rule "test"
when
Object()
then
System.out.println("Hello World!");
end
Finally this is the output I am seeing from my application...
[2010:06:180 18:06:144:info] ResourceChangeNotification created
[2010:06:180 18:06:147:info] ResourceChangeScanner created with default
interval=60
[2010:06:180 18:06:147:debug] ResourceChangeNotification monitor added
monitor=org.drools.io.impl.ResourceChangeScannerImpl@7d0b8078
[2010:06:180 18:06:149:info] KnowledgAgent created, with configuration:
monitorChangeSetEvents=true scanResources=true scanDirectories=true
[2010:06:180 18:06:149:info] KnowledegAgent has started listening for
ChangeSet notifications
(null: 3, 78): SchemaLocation: schemaLocation value =
'http://drools.org/drools-5.0/change-set.xsd' must have even number of
URI's.
(null: 3, 78): cvc-elt.1: Cannot find the declaration of element
'change-set'.
[2010:06:180 18:06:181:info] KnowledgAgent applying ChangeSet
[2010:06:180 18:06:182:debug] KnowledgeAgent subscribing to
resource=[ClassPathResource path='TestRules.drl']
[2010:06:180 18:06:182:debug] ResourceChangeNotification subscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@61176350 to
resource=[ClassPath
Resource path='TestRules.drl']
[2010:06:180 18:06:185:debug] ResourceChangeScanner subcribing
notifier=org.drools.io.impl.ResourceChangeNotifierImpl@46794afc to
resource=[ClassPathR
esource path='TestRules.drl']
[2010:06:180 18:06:187:debug] KnowledgeAgent ChangeSet requires
KnowledgeBuilder
[2010:06:180 18:06:187:debug] KnowledgeAgent rebuilding KnowledgeBase
using ChangeSet
[2010:06:180 18:06:315:debug] KnowledgeAgent building
resource=[ClassPathResource path='TestRules.drl']
java.lang.NoSuchMethodError:
org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()[Lorg/e
clipse/jdt/core/compiler/CategorizedProblem;
at
org.drools.commons.jci.compilers.EclipseJavaCompiler$3.acceptResult(Ecli
pseJavaCompiler.java:321)
at
org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:335)
at
org.drools.commons.jci.compilers.EclipseJavaCompiler.compile(EclipseJava
Compiler.java:351)
at
org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJa
vaCompiler.java:51)
at
org.drools.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.
java:389)
at
org.drools.compiler.DialectCompiletimeRegistry.compileAll(DialectCompile
timeRegistry.java:56)
at
org.drools.compiler.PackageRegistry.compileAll(PackageRegistry.java:74)
at
org.drools.compiler.PackageBuilder.compileAll(PackageBuilder.java:690)
at
org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:653)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java
:290)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.j
ava:488)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.ja
va:25)
at
org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgent
Impl.java:386)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentIm
pl.java:120)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentIm
pl.java:109)
Now I've checked all of the maven dependencies to make sure the they are
all there and I can doubly confirm everything is fine. In fact, I even
went so far to make sure the jars included in my app contained the
org.eclipse.jdt.core.compiler.CategorizedProblem.class file. The only
difference I've been able to think of so far is that my standalone
application uses the Java service wrapper where JBoss does not.
Any help is greatly appreciated.
Cheers,
Jean-Philippe Steinmetz
15 years, 5 months
How can I use retract in action or exception handler?
by EugeneP
Good afternoon
How can I use retract in action or exception handler?
For example,
0. I have a flow diagram;
1. in some node the fact Person( age == 10) is added to the working memory
by 'insert';
2. after some steps, the split node pass the control to the action-node
3. and in this action I need to retract this fact. How?!
The action MVEL code like:
$t : Person( age==10)
retract($t)
- does not work b/c of knowledge base errors:
"Could not parse knowledge... "
"Unable to build expression for action... "
"java.lang.Class cannot be cast to org.mvel2.util.MethodStub :
org.drools.lang.descr.ProcessDescr@fa54fe"
Thanks,
Eugene P
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-can-I-use-retract...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 5 months
"Not exists" on at least one element from the set
by LeoIo
Hi,
I am desperately trying to figure out how to express the following:
Having a set of object names, say (a,b,c) I want to write a rule firing when
there are no objects in working memory with name equals to at least one name
from the set.
In other words I want to say: fire if there are no objects with name 'a', or
no objects with name 'b' or no objects with name 'c'.
The rule "not Object(name in('a', 'b', 'c'))" only fires if none of the
objects exist.
What I need is different though.
Any help greatly appreciated.
Thanks a lot.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Not-exists-on-at-leas...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 5 months
Request for help to execute rule using drools5.0 from excel file
by Sanjib Karmakar
Hi
I am new in drools and in my project I would like to access rules in excel
file using drools 5.0
Please provide me the source code for how to access the rules in excel file.
I have done the following code
KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
DecisionTableConfiguration dtconf =
KnowledgeBuilderFactory.newDecisionTableConfiguration();
dtconf.setInputType( DecisionTableInputType.XLS );
dtconf.setWorksheetName("Tables");
kBuilder.add(ResourceFactory.newFileResource("TeamAllocationExample.xls"),
ResourceType.DTABLE, dtconf);
KnowledgeBuilderErrors errors = kBuilder.getErrors();
if (errors.size() > 0)
{
for (KnowledgeBuilderError error: errors) {
System.out.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kBuilder.getKnowledgePackages());
return kbase;
I am using the 'TeamAllocationExample.xls' - which is the default example I
found searching in net.
Here LHS and RHS portions are given - I would like to know how could I
execute the rule and get the result what is given under 'ACTION' column?
Please help me.
Thanks in advance
Sanjib
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Request-for-help-to-e...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 5 months
Regarding a fact model in Guvnor
by shekharputtur puttur
Hi ALL,
I have created a dynamic fact model in guvnor for creating rules.I want to
use the same fact model in my java application too.
How do i create a jar for the created model in guvnor and download the same?
Another way is to create a fact model in java(eclipse editor), and we can
upload the same for writing rules.
But for my application , i need to use the first approach.
i use guvnor 5.1.0M1.
Could you please tell me solution to do this?
Thanks & Regards
Shekhar
15 years, 5 months
Re: [rules-users] Drools Rule Engine - Tiered Rates
by Greg Barton
You can also try a data driven approach:
declare Rate
minUnits : int
maxUnits : int
revenuePercent : int
end
declare Sale
units : int
end
rule "FindRate"
when
r : Rate( )
s : Sale( units > r.minUnits, units < r.maxUnits )
then
System.out.println( "revenuePercent for " + s + " is " + r.getRevenuePercent());
end
Sample code attached.
--- On Wed, 6/9/10, Esteban Aliverti <esteban.aliverti(a)gmail.com> wrote:
From: Esteban Aliverti <esteban.aliverti(a)gmail.com>
Subject: Re: [rules-users] Drools Rule Engine - Tiered Rates
To: "Rules Users List" <rules-users(a)lists.jboss.org>
Date: Wednesday, June 9, 2010, 7:45 AM
Did you take a look at drools-template?http://hudson.jboss.org/hudson/job/drools/lastSuccessfulB...
Best,
On Wed, Jun 9, 2010 at 9:24 AM, ramram <ramram858(a)gmail.com> wrote:
Hi All,
I have the following question regarding Drools. The possibility to
implement tiered rates and that is I have the following example.
If the total units sold is between 0 - 1000 item a revenue return is 10%
while if the total units sold is between 1001- 2000 items the return is 20%.
I want to use 1 dynamic rule to implement the above example rather than
having 2 static rules defined? is this possible through drools?
Regards
Ram
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Rule-Engine-Ti...
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Esteban Aliverti
-----Inline Attachment Follows-----
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
15 years, 5 months