Caching of JBoss Rules bytecode field readers
by Keith Bennett
I found a link that might explain what is happening with the problem I
described in another posting (included below):
http://jira.jboss.com/jira/browse/JBRULES-1009
Mark Proctor, if you read this posting, can you please explain in more
detail how and why JBoss Rules generates bytecode field readers and
caches them by string name? I would appreciate it. Could this
explain the issue I'm experiencing as described below?
I have scoured the documentation and have tried many different
approaches to solving this problem, to no avail. I absolutely can not
get the new version of a .drl file to load with just an application
restart in Tomcat. I have to restart Tomcat each time. In my mind,
this has to be a classloader issue. I just don't know how to get
around it. I would really appreciate any help!
Keith
---------- Forwarded message ----------
From: Keith Bennett <forthwind(a)gmail.com>
Date: Wed, Jul 2, 2008 at 9:47 AM
Subject: New rules in source file not loaded when application redeployed
To: Rules Users List <rules-users(a)lists.jboss.org>
I am packaging my rules as a drl source file in a jar that is then
bundled in a war file that is then deployed to Tomcat. In my
implementation, the rulebase is cached the first time it is used in my
application, but when I add new rules to the source file and rebuild
my application then redeploy it on Tomcat, the new version of the
rules don't get loaded into the rulebase.
Why and how is an older version of the rules being loaded into the
rulebase when I redeploy my application in Tomcat? As FYI, I have
developed a business rules service that initializes the rulebase upon
a Spring container startup by loading the drl file from the classpath.
Is there an internal Drools static cache that is scoped to something
other than my application? The only thing I can do to load the new
rules is restart Tomcat. When I do this, the new version of the drl
source file is loaded and used, so I'm thinking the problem I'm having
is somehow related to the class loaders Tomcat uses, but I can't find
information about what Drools might be doing internally with a static
cache or something like that.
Can anyone explain what might be happening and how to configure Drools
and/or my application to get around this problem I'm having? I
definitely appreciate any help you can provide!
Keith
15 years, 9 months
Problem using RuleAgent
by Brian Trezise
I'm having a problem with the RuleAgent... I'm using a RuleAgent to load
rules and create a rulebase, but i'm finding that in the time it takes to
load all 30 or so files that I'm using for my rules, my main thread starts
running strings against the rules before all of the rules have been
initially loaded.
Is there an easy way to block until all rule-loading operations are
completed? This would be important for rule changes too, though not as much
so as on the initial load.
I'm thinking a listener sounds like the right way to go, but I'm not very
familiar with multi-threaded programming and so I don't really know how to
go about implementing that. Would somebody mind giving me a hand?
Thanks,
___________________________________________________
Brian Trezise
Staff Software Engineer
IntelliData, Inc
3173 s. uravan way
aurora, colorado 80013
T: 720.524.4864
brian.trezise(a)intellidata.net
15 years, 9 months
One question about "NOT"
by Senlin Liang
Hi all,
I checked the manual about "not", and it says:
==quote==
not' is first order logic's Non-Existential Quantifier and checks for
the non existence of something in the Working Memory. Think of 'not'
as meaning "there must be none of...". "
==end==
So there is no negation-as-failure, no stable model semantics, no well
founded semantics in Drools. Is it the case?
Thanks,
Senlin
15 years, 9 months
wordnet in drools
by Paul Fodor
Dear Sir,
I am new to Drools and I wonder if anyone used WordNet from Drools.
Basically, I want to make some simple joins, such as, find words that
are in the same synset, all hypernyms of a word, hyponyms, meronyms of
verbs, adjectives, etc.
Regards,
Paul Fodor
15 years, 9 months
One question about Database interface
by Senlin Liang
Hi all,
Is there some convinent database interface implemented in Drools
(store and retrieve data from DBMS, such as mysql) ?
I checked the manual, and found no such information. So I am assuming
that I will have to use JDBC. Is it right?
Thanks,
Senlin Liang
15 years, 9 months
one question about Transitive Closure
by Senlin Liang
Hi all,
Like the previous posts from Paul Fodor, we want to compute the
transitive closure of the following rules:
<code>
tc(X, Y) :- par(X, Y).
tc(X, Y) :- par(X, Z), tc(Z, Y).
</code>
We implemented it using Drools, and put them online at:
http://www.lmc.cs.sunysb.edu/~tests/drools_sliang/
Our question is that: is this implementation one of the most efficient
ones (in terms of computation time and memory usage)?
I run the tests and gave me "OutOfMemory" problems, while a similar
one can be easily tested in Jena. (Jena is another Java based
inference engine.)
Any idea will be greatly appreciated.
Best regards,
Senlin Liang
15 years, 9 months
AW: [rules-users] Eclipse plugin error: DRL-files in multiple folders?
by Tobias Abstreiter
Thanks for your answer Kris!
Finally I managed to get all my rule files into one single folder. But sadly this seems to be not enough. I still get a huge amount of errors in Eclipse, although running the application works fine.
Creating a ".package"-file with all the imports in it did not work, so I inserted the imports in all rule files (more than 100 files - phew!). This eliminated half of the errors, but there are still many (~500) left.
I get errors, when I call a function with an container class as parameter out of another function:
> The method getNewComponentName(ArrayList, String) is undefined for the type H2GInitialisePlanCellWithoutWirkCell TFW/src/rules createData_2_createplan_functions_0_initialise_H2G_Cell.drl line 75 1215533608869 1837
The parameters used in the function call are an ArrayList and a String, i really have no clue why this error appears.
There are import errors, but the used imports are all declared correctly in the rule files.
And some very strange things like this:
> The method setTrxFreq(H2GW_TrxFreq) in the type H2GW_Trx is not applicable for the arguments (H2GW_TrxFreq) TFW/src/rules createData_1_createwirk_functions_1_create_H2g_CreateNetworkForBts.drl line 183 1215531032918 1821
Huh?
I am really stumped and have no idea what i should try next. Drools is a great piece of software, but having no support in the IDE writing rules is really hard.
Should i try to put all shared functions and imports into one big file? This would mean a lot of work and I would prefer another solution.
Any helping comment welcome!
Thanks!
Bye, Tobias
__________________________________________________________________
MicroNova electronic GmbH
Tobias Abstreiter
Telekommunikation & Netzmanagment
Unterfeldring 17
D-85256 Vierkirchen
Tel.: +49 (08139) 93 00-42
Fax.: +49 (08139) 93 00-80
eMail: Tobias.Abstreiter(a)micronova.de
Web: http://www.micronova.de
Geschäftsführer: Josef W. Karl - Sitz der Gesellschaft: Jetzendorf
Registergericht: Ingolstadt - HRB-Nr.: 181 373
__________________________________________________________________
-----Ursprüngliche Nachricht-----
Von: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] Im Auftrag von Kris Verlaenen
Gesendet: Donnerstag, 26. Juni 2008 14:52
An: Rules Users List
Betreff: Re: [rules-users] Eclipse plugin error: DRL-files in multiple folders?
> The IDE allows you to define shared definitions (e.g. functions and imports) in a file with extension .package (instead of the normal .drl). This .package file should be in the same directory as the rules that use it, the IDE is not capable of searching other folders at this point.
>
> Kris
> ----- Original Message -----
> From: "Tobias Abstreiter" <Tobias.Abstreiter(a)micronova.de>
> To: <rules-users(a)lists.jboss.org>
> Sent: Tuesday, June 24, 2008 6:41 PM
> Subject: [rules-users] Eclipse plugin error: DRL-files in multiple folders?
>
>
> > Hi!
> >
> > I have a problem using the drools Eclipse plugin 4.0.7 (with Drools
> > 4.0.7).
> > In our project rules are located in different folders. One of it is called
> > "global" (containing many functions, imports, ...) whereon most of the
> > rules in the other folders depend. The package name is identical.
> >
> > Running the application works fine but the Eclipse plugin reports many
> > "... cannot be resolved"-errors when I convert the Eclipse Java project
> > into a Drools project. I believe that the plugin has problems to find all
> > rule files. Is that possible?
> > Is there a way to tell the plugin to look in multiple rule-folders?
> >
> > Thanks in advance,
> > Tobias
15 years, 9 months
Approach for poor man's backtracking?
by Ingomar Otter
Hello,
I am looking for an approach to implement "poor man's backtracking" in
Drools.
What I am trying to do is to collect "the impact" of alternate
decisions. In some situations I can not "decide" which path to follow
and what I need to do is to explore several paths and take a decision
based on that results. What I have done so far is to collect the
alternatives as I find them in a list and inserted them one by one.
What I need to do then is to restore the state (backtrack) after I
have explored one path.
My initial approach was to use logicals for this (insert the
"hypothesis", see what happens/ collect the results and retract the
hypothesis). However this messes with the rest of my ruleset quite a
bit. Then I was thinking of maintaining special flags on the asserted
facts but this seems like a kludge to me. So I was wondering whether
someone is aware of a more elegant / generic approach to implement
such backtracking with Drools.
Any hints appreciated.
Cheers,
Ingomar
15 years, 9 months
Rules 'firing' multiple times?
by pramod george
Hi all.
I have this question on drools rules and I'm not sure if this
is the right thinking?
I have a rule defined in a drl file:
when
c: Emp_Crime_Record(DISPOSITION == "GUILTY");
then
System.out.println("CriminalRecordRule fired...");
end
Here, if the table "Emp_Crime_Record" is got 5 rows that satisfy this condition ie:- DISPOSITION == "GUILTY", then does this rule get fired
5 times? Ie:- the sop gets printed 5 times?
For this, if there are a million records that satisfy this condition - then the firing happens a million times?
I would be greatful if this can be clarified?
Thanks a million! :)
-Promod
15 years, 9 months
question about updating main memory
by Senlin Liang
Hi all,
I am trying to insert some object, querying them and the retract them.
My question, when I query the inserted objects using defined "query",
it return 0 objects. But when I iterate over all objects in WM, the
objects are returned.
Any information is appreciated!
Files:
===================test.drl====================
package tests;
query "selectQuery"
p : ClassP()
end
==================end of test.drl================
==================Test.java====================
package tests;
import java.io.*;
import java.io.InputStreamReader;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.StatefulSession;
import org.drools.compiler.PackageBuilder;
import org.drools.QueryResult;
import org.drools.QueryResults;
import org.drools.FactHandle;
import java.util.Iterator;
public class Test {
public static void main (String args[]) {
try {
Reader source = new
InputStreamReader(Test.class.getResourceAsStream("../test.drl"));
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl(source);
if (builder.hasErrors()) {
System.out.println(builder.getErrors().toString());
System.exit(0);
}
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(builder.getPackage());
final StatefulSession session = ruleBase.newStatefulSession();
System.out.println("Inserting objects ...");
for (int i = 0; i < 5; i ++) {
session.insert(new ClassP(1, i));
}
System.out.println("Querying objects ...");
QueryResults results = session.getQueryResults("selectQuery");
System.out.println("ResultSize = " + results.size());
/***************************************************************************************
Here, it reports results.size() is 0, and there should be
5 objects in WM right now. It is
the place I got the question.
I have no idea whether I am using the "query" correctly.
Anything wrong?
***************************************************************************************/
for (Iterator it = results.iterator(); it.hasNext(); ) {
final QueryResult result = (QueryResult) it.next();
ClassP p = (ClassP) result.get("p");
System.out.println("p(" + p.getFirst() + ", " + p.getSecond()+")");
}
System.out.println("Deleting ...");
for (Iterator it = session.iterateFactHandles(); it.hasNext(); ) {
FactHandle factHandle = (FactHandle) it.next();
ClassP p = (ClassP) session.getObject(factHandle);
System.out.println("p(" + p.getFirst() + ", " + p.getSecond()+")");
session.retract(factHandle);
}
/***************************************************************************************
Here, it prints out: it is deleting p(1, 1), ... p(1, 5).
It verifies that there are the 5 objects inserted.
***************************************************************************************/
session.dispose();
} catch (Exception e) {
System.out.println(e);
System.exit(0);
}
}
public static class ClassP {
private int first;
private int second;
public ClassP() {}
public ClassP(int firstIn, int secondIn) {
this.first = firstIn;
this.second = secondIn;
}
public int getFirst() {
return this.first;
}
public int getSecond() {
return this.second;
}
}
}
========================end of Test.java=====================
Thanks a lot,
--
Senlin Liang
15 years, 9 months