Drools and Guvnor 5.1M2 - Exception being thrown in processChangeSet
by Jeffrey Schneller
I am trying to upgrade to the 5.1M2 build from 5.0.1 and am running into
some issues. I have installed the new 5.1 Guvnor and imported the rules
from my 5.0.1 Guvnor instance.
I then removed the old 5.0.1 drools jars from my app and replaced them
with the 5.1M2 drools jars. I was also added all the dependent
libraries. The code that worked with the 5.0.1 version does not work
with the 5.1M2 version. In 5.0.1 I was constructing the xml and
streaming it into the applyChangeSet method. With 5.1M2 I am just
pointing to the change set xml file that is in the Guvnor.
I am seeing a NullPointerException being thrown in the processChangeSet
method as shown below.
Caused by: java.lang.NullPointerException
at
org.drools.agent.impl.KnowledgeAgentImpl.processChangeSet(KnowledgeAgent
Impl.java:171)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentIm
pl.java:143)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentIm
pl.java:130)
Did I miss something? Am I doing something wrong? Below is the code
that I have.
KnowledgeAgentConfiguration kaconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
kaconf.setProperty( "drools.agent.scanDirectories",
"true" );
kaconf.setProperty("drools.agent.newInstance",
"false");
ResourceFactory.getResourceChangeScannerService().start();
ResourceFactory.getResourceChangeNotifierService().start();
String url =
"http://rulerserver/drools-guvnor/org.drools.guvnor.Guvnor/package/my.ru
le.package/LATEST/ChangeSet.xml";
KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent( "Configuration", kaconf );
kagent.setSystemEventListener(new MyDroolsListener());
try {
kagent.applyChangeSet(ResourceFactory.newUrlResource(new URL(url)));
// ERROR IS OCCURING INSIDE OF applyChangeSet
} catch (MalformedURLException e) {
e.printStackTrace();
}
14 years, 5 months
Unqualified type in strict mode error & java.io.InvalidCastException: org.drools.rule.DialectRuntimeRegistry error
by Ike Okafo
Hi
I got a great answer to my last post and will like to say thank you to
Jeffrey Schneller. I hope to contribute to the
community once my drools knowledge base grows
I have two quick follow up questions to my last post
(1) I imported some rules validate which succesfully within guvnor but I
have a couple of other rules that use maps on which I am getting errors.
The map contains objects of a certain type Class1 and the map key is a Long
(e.g 1L, 2L). The statement causing the error is of the format
eval(Map[1L].getDirection== Map[2L].getDirection). The error I get is
"unqualified type in strict mode for getDirection". I scoured the forums for
a solution and learnt that I need to cast the object from the map to its
specific type before calling any method of the class and so I changed it to
eval(((Class1)Map[2L]).getDirection == ((Class1)Map[3L]).getDirection) but
the errors only got worse.
Is there a resolution for this "unqualified type in strict mode" error?
I should also mention that I get no such error when working with the .DRL
file in my java code outside guvnor.
(2) The second issue I am dealing with involves those rules that validated
in guvnor (I am running guvnor under JBOSS 4.2.3). I validated and built the
package successfully (I did not create a snapshot for deployment). I then
tried to reference the guvnor package to build the rulebase using the
following java code
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...
I got this url from the guvnor deployment page
The error I got when I ran this was "java.io.InvalidCastException:
org.drools.rule.DialectRuntimeRegistry; local class incompatible: stream
classdesc serailVersionUID= 5308493362083281112, local class serialVersionID
= 510
Is there a compatibility issue between Guvnor and JBOSS 4.2.3
Thanks
14 years, 6 months
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
14 years, 6 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.
14 years, 6 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
14 years, 6 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
14 years, 6 months