Re: [rules-users] Ant Build of PKG with Declared Types
by Ansgar Konermann
Am 23.09.2011 20:03 schrieb "TroyL" <troylparrish(a)aol.com>:
>
> Thank you for the reply. I have run a number of much simpler applications
in
> several environments, below are my results:
>
> My Ant Script remains unchanged.
Next things to try could be:
- increase verbosity of your ant compile so you can see what is actually
being compiled.
- make sure the Ant build is as similar as possible to your unit test
(observe verbose output of Ant build carefully)
Best regards,
Ansgar
>
> *My Test Application*:
>
> KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
>
builder.add(ResourceFactory.newClassPathResource("declaredType.drl"),
> ResourceType.DRL);
>
> if(builder.hasErrors()){
> System.out.println(builder.getErrors().toString());
> }
>
> KnowledgeBase base =
KnowledgeBaseFactory.newKnowledgeBase();
> base.addKnowledgePackages(builder.getKnowledgePackages());
>
> StatefulKnowledgeSession session =
base.newStatefulKnowledgeSession();
>
> Test test = new Test();
> test.setName("Test");
>
> session.insert(test);
> session.fireAllRules();
>
> session.dispose();
>
> *My DRL*:
>
> package com.test
>
> declare SubTest
>
> name : String
> id : int
>
> end
>
> rule "Test Rule"
>
> when
> Test(name == "Test")
> then
> SubTest sTest = new SubTest();
> sTest.setName("SubTest");
> sTest.setId(12);
> System.out.println("Test Ran");
> System.out.println(sTest.getName() + " " + sTest.getId());
>
> end
>
> When I run my test application the drl compiles and I get the following
> output to the console:
>
> Test Ran
> SubTest 12
>
> However I get the following error when trying to compile it with the Ant
> Script:
>
> [compiler] Duplicate type definition. A class with the name
> 'com.test.SubTest' was found in the classpath while
>
> trying to redefine the fields in the declare statement. Fields can only be
> defined for non-existing classes.
>
> BUILD FAILED
> C:\Users\troy.l\conceptsWorkspace\DeclaredType\build1.xml:23: RuleBaseTask
> failed: Duplicate type definition. A
>
> class with the name 'com.test.SubTest' was found in the classpath while
> trying to redefine the fields in the
>
> declare statement. Fields can only be defined for non-existing classes.
>
> This error goes away when the Declared Type has only one field IE:
>
> declare SubTest
>
> name : String
>
> end
>
> The drl compiles into a PKG and the I can successfully use the PKG in my
> test application when the Declared Type has only one field. Also I do not
> have this issue in other Drools versions (I have tried 5.1.1, 5.0.1 and
> 5.2.0.M2).
>
> This is a stand alone test application and the above represents almost the
> entire test project with the exception of the Test.java class which is a
> pojo.
>
> Thanks again for responding.
>
> --
> View this message in context:
http://drools.46999.n3.nabble.com/Re-rules-users-Ant-Build-of-PKG-with-De...
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
14 years, 10 months
Re: [rules-users] Ant Build of PKG with Declared Types
by Ansgar Konermann
Am 16.09.2011 16:15 schrieb "TroyL" <troylparrish(a)aol.com>:
>
> I am attempting to build a PKG utilizing an Ant Script. My DRL includes
two
> declared types. When the declared types have only one field the PKG will
> compile but when the declared types have more than one field I get an
error
> stating that a class of that name was already found on the class path :
> specifically the error states:
>
> [compiler] Duplicate type definition. A class with the name XXXXXXX was
> found in the classpath while trying to redefine the fields in the declare
> statement. Fields can only be defined for non-existing classes.
Hi,
please optimize your signal/noise ratio:
* try to reduce your use case to a minimal test case which still exhibits
the erroneous behaviour
* a self contained unit test would be perfect
* try compiling the files from your use case using a plain KnowledgeBuilder.
As the Ant task is merely a wrapper around it, try to reproduce the
erroneous behaviour with the simplest setup possible.
* put the rule source code into your test as string literals.
* reduce the rule source code as much as possible while still reproducing
the error
* then, identify the smallest rule source code delta which makes the error
go away.
If you finally manage to reproduce the error using this minimal setup, make
sure to include complete information. In particular, don't XXX out parts of
the error message.
I'm quite sure if you follow at least some of these hints, you will probably
get more feedback from this list.
Best regards,
Ansgar
>
> My ant script:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <project default="rules">
> <property name="projectPath" value="" />
> <property name="droolsPath"
> value="C:/Users/266571/Documents/drools-distribution-5.2.0.Final/binaries"
> />
> <property name="eclipsePath"
> value="C:/Users/266571/Documents/eclipse/plugins" />
>
>
> <path id="drools.classpath">
> <pathelement location="${droolsPath}/drools-ant-5.2.0.FINAL.jar" />
> <pathelement location="${droolsPath}/drools-api-5.2.0.jar" />
> <pathelement location="${droolsPath}/drools-core-5.2.0.FINAL.jar" />
> <pathelement location="${droolsPath}/drools-compiler-5.2.0.FINAL.jar"
/>
> <pathelement location="${droolsPath}/antlr-runtime-3.3.jar" />
> <pathelement location="${droolsPath}/mvel2-2.0.19.jar" />
> <pathelement location="${droolsPath}/knowledge-api-5.2.0.Final.jar" />
> <pathelement
> location="${eclipsePath}/org.eclipse.jdt.core_3.6.2.v_A76_R36x.jar" />
>
> </path>
> <path id="model.classpath">
> <pathelement location="bin" />
> </path>
> <taskdef name="compiler" classpathref="drools.classpath"
> classname="org.drools.contrib.DroolsCompilerAntTask" />
> <target name="rules" >
> <compiler
> srcdir="${projectPath}src/rules"
> tofile="${projectPath}src/rules/rules.pkg"
> binformat="package"
> classpathref="model.classpath" >
> <include name="supportObjects.drl" />
> </compiler>
> </target>
>
>
> </project>
>
> My DRL:
>
> package gov.ssa.codedObjects
>
> import gov.ssa.codedObjects.SupportObjectsCollection;
>
> declare SecondaryBrain
>
> name : String
> id : int
>
> end
>
> declare ICDCode
>
> code : String
> name : String
>
> end
>
> global SupportObjectsCollection supportObjectsList;
>
> rule "Evaluate Coded Object"
>
> when
> $codedObject : CodedObject(code == 191.0)
> then
> SecondaryBrain brain = new SecondaryBrain();
> brain.setName("Brain Tumor, Cerebrum");
> insert (brain);
> end
>
>
> rule "Evaluate Coded Object Malignent"
>
> when
> $codedObject : CodedObject(code == "239.6" || code ==
"C71.9", $code :
> code)
>
> then
> ICDCode code = new ICDCode();
> code.setCode($code);
> code.setName("Neoplasm of uspecified nature of the Brain");
> insert(code);
>
> end
>
>
>
> rule "Add Brain Neoplasm to List"
>
> when
> $code : ICDCode(code == "239.6" || code == "C71.9")
> then
> supportObjectsList.addToSupportObjects($code);
>
> end
>
> rule "Megaduodenum"
>
> when
> $codedObject : CodedObject(code == "537.3" || code ==
"K59.3", $code :
> code)
>
> then
> ICDCode code = new ICDCode();
> code.setCode($code);
> code.setName("Megaduodenum");
> insert(code);
>
>
> end
>
> rule "Add Megaduodenum to List"
>
> when
> $code : ICDCode(code == "537.3" || code == "K59.3")
> then
> supportObjectsList.addToSupportObjects($code);
>
> end
>
>
> Any suggestions would be helpful.
>
> --
> View this message in context:
http://drools.46999.n3.nabble.com/Ant-Build-of-PKG-with-Declared-Types-tp...
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
14 years, 10 months
Fusion and open-ended intervals?
by Barry Kaplan
A fusion design question:
I have events that represent intervals. Initially the intervals are
open-ended (kind a like the current state of an entity). Other events are
matched "during" the interval and correlated. At some point the interval
will be closed (eg, a specific downtime interval is closed because the
device is no online again).
All the events in this system are immutable -- so if some property of an
event changes, it is cloned and modified in working-memory. For the case of
the interval events, initially the interval is inserted open-ended, and at
some point later closed and then modified.
This does not work with fusion however, since an event's duration is
maintained by the fact-handle not the event itself. Hence a modify with a
now closed interval (ie, a finite @duration) has no effect. I'm guessing the
temporal values are maintained the handle to ensure stable values for the
behaviors that trigger based on temporal values, which is reasonable.
So I'm looking for alternative designs. Some are:
1) Modeled the intervals as begin/end events, but that gets messy real
fast (have to correlate
the begin/end events somehow, can't use evaluators like 'includes' or
'during', etc).
2) Retract the interval event when it is closed (this way closed intervals
no longer correlate
with other incoming events). But then we really have a manually
maintained state machine
using only facts, and there can be no reasoning over a series these
interval events.
(eg, 3 downtimes longer than 2 minutes in the last hour).
Opinions?
-barry
--
View this message in context: http://n3.nabble.com/Fusion-and-open-ended-intervals-tp719076p719076.html
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 10 months
CEP sliding window in the past
by cfuser
Can you offset the sliding window functionality to look for a window in the
past? What I'm trying to do is offset the window from 'now'. E.g.
Assuming it is 12:05 and I have been receiving objects for 5 minutes, I'm
trying to get this to sum received objects between 2 and 3 minutes ago.
rule "Accumulate attempts over 1 minute (window over time)"
when
$measure : Number()
from accumulate( MyData( $m:measures["attempts"],
objectType=="climber" )
over window:time( 2m, 3m ) from entry-point "My Stream",
sum($m))
then
#
end
Looking at the SlidingTimeWindow source code, it looks as though you can't
offset the window by a delay? Is that accurate? If you can't do that
directly via a sliding window, is there a way to work around this?
TIA.
--
View this message in context: http://drools.46999.n3.nabble.com/CEP-sliding-window-in-the-past-tp331463...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 10 months
Help with URL resource caching
by benji2212
I'm using KnowledgeAgent to poll regularly for three DRL files hosted on a
web server. If the web server goes down for any reason or one of the DRL
files becomes unavailable, the change scanner and knowledge agent
unsubscribe from the resource(s) that were unavailable.
After reading some topics on the forum, I found that setting the
drools.resource.urlcache system property should correct this. However, I've
been unable to get this to work properly. The code I'm using is below. Any
insight into what I'm doing wrong would be appreciated. I'm using drools
5.1.1.
System.setProperty("drools.dateformat",
"MM/dd/yyyy");
System.setProperty("drools.resource.urlcache",
"C:\\Users\\0000000\\Documents\\rule-cache");
//start the scanner service and resource change notifier service
changeNotifier = ResourceFactory.getResourceChangeNotifierService();
changeScanner = ResourceFactory.getResourceChangeScannerService();
changeNotifier.start();
changeScanner.start();
kagent = KnowledgeAgentFactory.newKnowledgeAgent("My Knowledge Agent");
URL url = RulesRuntimeImpl.class.getResource(CHANGE_SET_PATH);
Resource drl = ResourceFactory.newUrlResource(url);
kagent.applyChangeSet(drl);
My change set file looks like this:
<change-set xmlns="http://drools.org/drools-5.0/change-set"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/change-set
drools-change-set-5.0.xsd" >
<add>
<resource source="http://mysite.com/test/FirstDecisionTable.drl"
type="DRL" />
<resource source="http://mysite.com/test/SecondDecisionTable.drl"
type="DRL" />
<resource source="http://mysite.com/test/ThirdDecisionTable.drl"
type="DRL" />
</add>
</change-set>
and the output I get when a resource in the change set becomes unavailable:
[9/21/11 10:49:28:015 EDT] 0000004e SystemOut O [2011:09:264
10:09:15:debug] ResourceChangeScanner attempt to scan 3 resources
[9/21/11 10:49:28:046 EDT] 0000004e SystemOut O [2011:09:264
10:09:46:debug] ResourceChangeScanner thread is waiting for 60 seconds.
[9/21/11 10:50:28:055 EDT] 0000004e SystemOut O [2011:09:264
10:09:55:debug] ResourceChangeScanner attempt to scan 3 resources
[9/21/11 10:50:28:259 EDT] 0000004e SystemOut O [2011:09:264
10:09:259:debug] ResourceChangeScanner removed resource=[UrlResource
path='http://mysite.com/test/FirstDecisionTable.drl']
[9/21/11 10:50:28:309 EDT] 0000004e SystemOut O [2011:09:264
10:09:309:debug] ResourceChangeNotification received ChangeSet notification
[9/21/11 10:50:28:345 EDT] 0000004e SystemOut O [2011:09:264
10:09:345:debug] ResourceChangeScanner thread is waiting for 60 seconds.
[9/21/11 10:50:28:426 EDT] 0000004f SystemOut O [2011:09:264
10:09:417:debug] ResourceChangeNotification processing ChangeSet
[9/21/11 10:50:28:535 EDT] 0000004f SystemOut O [2011:09:264
10:09:535:debug] ResourceChangeNotification ChangeSet removed
resource=[UrlResource path='http://mysite.com/test/FirstDecisionTable.drl']
for listener=org.drools.agent.impl.KnowledgeAgentImpl@6e5a6e5a
[9/21/11 10:50:28:560 EDT] 0000004f SystemOut O [2011:09:264
10:09:560:debug] KnowledgeAgent received ChangeSet changed notification
[9/21/11 10:50:28:611 EDT] 0000004f SystemOut O [2011:09:264
10:09:611:debug] ResourceChangeNotification thread is waiting for queue
update
[9/21/11 10:50:28:626 EDT] 00000050 SystemOut O [2011:09:264
10:09:625:info] KnowledgeAgent applying ChangeSet
[9/21/11 10:50:28:663 EDT] 00000050 SystemOut O [2011:09:264
10:09:663:debug] KnowledgeAgent removing mappings for resource=[UrlResource
path='http://mysite.com/test/FirstDecisionTable.drl'] with unsubscribe=true
[9/21/11 10:50:28:684 EDT] 00000050 SystemOut O [2011:09:264
10:09:684:debug] KnowledgeAgent notifier unsubscribing to
resource=[UrlResource path='http://mysite.com/test/FirstDecisionTable.drl']
[9/21/11 10:50:28:689 EDT] 00000050 SystemOut O [2011:09:264
10:09:689:debug] ResourceChangeNotification unsubscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@6e5a6e5a to
resource=[UrlResource path='http://mysite.com/test/FirstDecisionTable.drl']
[9/21/11 10:50:28:689 EDT] 00000050 SystemOut O [2011:09:264
10:09:689:debug] KnowledgeAgent rebuilding KnowledgeBase using ChangeSet
...
--
View this message in context: http://drools.46999.n3.nabble.com/Help-with-URL-resource-caching-tp336204...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 10 months
Issue using global 'variable' with Drools 5.2 in DRL
by Slorg1
Good evening,
I am porting our project from Drools 5.1 to Drools 5.2 and I am running into
a couple of issues. Most I solved except:
It seems that our global variable is being completely ignored.
I have declared the following after package & imports :
global java.util.Date now;
When calling it in a rule:
rule "MyRule"
when
EXPRESSION >= now.time
then
// things to do
end
Then I get the following error at 'compile' time :
Not possible to directly access the property 'time' of declaration 'now'
since it is not a pattern
I do not know what to make of it.
I have tried to change it to now.getTime() without success.
Thank you in advance for your help.
--
View this message in context: http://drools.46999.n3.nabble.com/Issue-using-global-variable-with-Drools...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 10 months
Ant Build of PKG with Declared Types
by TroyL
I am attempting to build a PKG utilizing an Ant Script. My DRL includes two
declared types. When the declared types have only one field the PKG will
compile but when the declared types have more than one field I get an error
stating that a class of that name was already found on the class path :
specifically the error states:
[compiler] Duplicate type definition. A class with the name XXXXXXX was
found in the classpath while trying to redefine the fields in the declare
statement. Fields can only be defined for non-existing classes.
My ant script:
<?xml version="1.0" encoding="UTF-8" ?>
<project default="rules">
<property name="projectPath" value="" />
<property name="droolsPath"
value="C:/Users/266571/Documents/drools-distribution-5.2.0.Final/binaries"
/>
<property name="eclipsePath"
value="C:/Users/266571/Documents/eclipse/plugins" />
<path id="drools.classpath">
<pathelement location="${droolsPath}/drools-ant-5.2.0.FINAL.jar" />
<pathelement location="${droolsPath}/drools-api-5.2.0.jar" />
<pathelement location="${droolsPath}/drools-core-5.2.0.FINAL.jar" />
<pathelement location="${droolsPath}/drools-compiler-5.2.0.FINAL.jar" />
<pathelement location="${droolsPath}/antlr-runtime-3.3.jar" />
<pathelement location="${droolsPath}/mvel2-2.0.19.jar" />
<pathelement location="${droolsPath}/knowledge-api-5.2.0.Final.jar" />
<pathelement
location="${eclipsePath}/org.eclipse.jdt.core_3.6.2.v_A76_R36x.jar" />
</path>
<path id="model.classpath">
<pathelement location="bin" />
</path>
<taskdef name="compiler" classpathref="drools.classpath"
classname="org.drools.contrib.DroolsCompilerAntTask" />
<target name="rules" >
<compiler
srcdir="${projectPath}src/rules"
tofile="${projectPath}src/rules/rules.pkg"
binformat="package"
classpathref="model.classpath" >
<include name="supportObjects.drl" />
</compiler>
</target>
</project>
My DRL:
package gov.ssa.codedObjects
import gov.ssa.codedObjects.SupportObjectsCollection;
declare SecondaryBrain
name : String
id : int
end
declare ICDCode
code : String
name : String
end
global SupportObjectsCollection supportObjectsList;
rule "Evaluate Coded Object"
when
$codedObject : CodedObject(code == 191.0)
then
SecondaryBrain brain = new SecondaryBrain();
brain.setName("Brain Tumor, Cerebrum");
insert (brain);
end
rule "Evaluate Coded Object Malignent"
when
$codedObject : CodedObject(code == "239.6" || code == "C71.9", $code :
code)
then
ICDCode code = new ICDCode();
code.setCode($code);
code.setName("Neoplasm of uspecified nature of the Brain");
insert(code);
end
rule "Add Brain Neoplasm to List"
when
$code : ICDCode(code == "239.6" || code == "C71.9")
then
supportObjectsList.addToSupportObjects($code);
end
rule "Megaduodenum"
when
$codedObject : CodedObject(code == "537.3" || code == "K59.3", $code :
code)
then
ICDCode code = new ICDCode();
code.setCode($code);
code.setName("Megaduodenum");
insert(code);
end
rule "Add Megaduodenum to List"
when
$code : ICDCode(code == "537.3" || code == "K59.3")
then
supportObjectsList.addToSupportObjects($code);
end
Any suggestions would be helpful.
--
View this message in context: http://drools.46999.n3.nabble.com/Ant-Build-of-PKG-with-Declared-Types-tp...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 10 months
Facing an inconsistent error executing rules during runtime
by S_Kumar_P@DELLTEAM.com
Hi,
I am getting an error at inconsistent intervals while executing one scheduled task, which uses rules, in Websphere AS. Below is the error trace,
[9/22/11 8:57:59:316 CDT] 0000004d SystemErr R Caused by: java.lang.ClassNotFoundException: autoclassification.Rule_10___10_Auto_Classification_0DefaultConsequenceInvoker
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:163)
at org.drools.rule.DroolsCompositeClassLoader.loadClass(DroolsCompositeClassLoader.java:91)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at org.drools.rule.JavaDialectRuntimeData.wire(JavaDialectRuntimeData.java:312)
at org.drools.rule.JavaDialectRuntimeData.reload(JavaDialectRuntimeData.java:379)
at org.drools.rule.JavaDialectRuntimeData.onBeforeExecute(JavaDialectRuntimeData.java:139)
at org.drools.rule.DialectRuntimeRegistry.onBeforeExecute(DialectRuntimeRegistry.java:132)
at org.drools.compiler.PackageBuilder.reloadAll(PackageBuilder.java:683)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:641)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:266)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:458)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
at com.dell.compliance.middleware.ruleengine.RuleEngine.fire(RuleEngine.java:43)
The rules are:
package autoclassification;
import com.dell.compliance.middleware.business.Part;
import java.util.Map;
function boolean like(String masterData, String transData) {
boolean result = false;
if (masterData == null) {
return result;
}
if (transData != null && transData.trim().length() > 0) {
if (transData.trim().startsWith('%')
&& !transData.trim().endsWith('%')) {
result = masterData.endsWith(removeChar(transData));
}
else if (!transData.trim().startsWith('%')
&& transData.trim().endsWith('%')) {
result = masterData.startsWith(removeChar(transData));
}
else if (transData.trim().startsWith('%')
&& transData.trim().endsWith('%')) {
result = masterData.contains(removeChar(transData));
} else {
result = masterData.equals(transData);
}
}
return result;
}
function String removeChar(String transData) {
String str = transData.replaceAll('%', '');
return str;
}
function boolean validateTechAttribute(Map taMap, String attrNames, String attrVals) {
boolean result = false;
if (attrNames == null || attrVals == null) {
return true;
}
if(taMap == null){
return false;
}
String[] attrs = attrNames.split('[|]');
String[] values = attrVals.split('[|]');
String attr = null;
String value = null;
String attrVal = null;
for (int i = 0; i < attrs.length; i++) {
attr = attrs[i] != null ? attrs[i].trim().toUpperCase() : '';
value = values[i] != null ? values[i].trim().toUpperCase() : '';
if (taMap.containsKey(attr)) {
attrVal = (String) taMap.get(attr);
result = like(attrVal, value);
if(result==false){
return result;
}
} else {
return false;
}
}
return result;
}
rule '2 - 2_Auto Classification'
when
part : Part(eval (like(partType,'Hard Drive (NBK)')) , eval (like(partClass,'Drive,Hard')) , eval (validateTechAttribute(techAttrList,'Placement|Encrypted Drive','Internal|No')))
then
part.setPartDesc('HARD DRIVE-INTERNAL');
update(part);
drools.getWorkingMemory().clearAgenda();
end
rule '3 - 3_Auto Classification'
when
part : Part(eval (like(partType,'Hard Drive (NBK)')) , eval (like(partClass,'Drive,Hard')) , eval (validateTechAttribute(techAttrList,'Placement|Encrypted Drive','Internal|Yes')))
then
part.setPartDesc('HARD DRIVE-INTERNAL-ENCRYPTED');
update(part);
drools.getWorkingMemory().clearAgenda();
end
--
--
--
rule '9 - 9_Auto Classification'
when
part : Part(eval (like(partType,'Card,Network')) , eval (like(partClass,'CARD,NETWORK')) , eval (validateTechAttribute(techAttrList,'Wireless |SWIncludesEncryption','no|Yes')))
then
part.setPartDesc('POPULATED PCB-NETWORK-ADAPTER-ENCRYPTED');
update(part);
drools.getWorkingMemory().clearAgenda();
end
rule '10 - 10_Auto Classification'
when
part : Part(eval (like(partType,'Card,Wireless')) , eval (like(partClass,'CARD,NETWORK')) , eval (validateTechAttribute(techAttrList,'Wireless |SWIncludesEncryption','yes|Yes')))
then
part.setPartDesc('POPULATED PCB-NETWORK WIRELESS WLAN');
update(part);
drools.getWorkingMemory().clearAgenda();
end
And the Code loading rules is in RuleEngine.java as:
public void fire(byte[] rules, Object obj) {
final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
// this will parse and compile in one step
kbuilder.add(ResourceFactory.newByteArrayResource(rules),ResourceType.DRL);
// Check the builder for errors
if (kbuilder.hasErrors()) {
System.out.println(kbuilder.getErrors().toString());
throw new RuntimeException("Unable to compile drl.");
}
// get the compiled packages (which are serializable)
final Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages();
// add the packages to a knowledgebase (deploy the knowledge packages).
final KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(pkgs);
final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
ksession.addEventListener(new DebugAgendaEventListener());
ksession.addEventListener(new DebugWorkingMemoryEventListener());
// setup the audit logging
//KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "log/drools.log");
ksession.insert(obj);
ksession.fireAllRules();
//logger.close();
ksession.dispose();
}
We used Drools 5.1,
Please help me resolve as soon as possible.
Thanks & Regards
Santhosh
14 years, 10 months
Exception in Banking Tutorial in Drools expert guide...
by Manohar Kokkula
Hi,
I am trying to execute Banking Tutorial Example given in Drools expert(
http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/ht...
),but im getting following error,
Exception in thread "main" java.lang.ClassCastException:
java.util.ArrayList cannot be cast to org.hibernate.mapping.Collection
at com.sample.RuleRunner.runRules(RuleRunner.java:32)
at com.sample.Example1.main(Example1.java:5)
And when i try to resolve this i am getting another error:
java.lang.ArrayIndexOutOfBoundsException: 0
at com.code.RuleRunner.runRules(RuleRunner.java:45)
at com.code.Example1.main(Example1.java:5)
Code snippet :
for (int i=0; i <=facts.length;i++)
{
System.out.println("222");
Object fact = facts[i]; //The error is for this line of
code
System.out.println( "Inserting fact: " + fact );
ksession.insert(fact);
System.out.println("333");
}
could any body help me on this.
Manohar Kokkula
Mailto: manohar.kokkula(a)tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
14 years, 10 months