Re: [rules-dev] rules-dev Digest, Vol 33, Issue 14
by Nikhil S. Kulkarni
Hi,
Apologies for Posting this on dev.
-----Original Message-----
From: rules-dev-bounces(a)lists.jboss.org [mailto:rules-dev-bounces@lists.jboss.org] On Behalf Of rules-dev-request(a)lists.jboss.org
Sent: Wednesday, September 16, 2009 7:36 PM
To: rules-dev(a)lists.jboss.org
Subject: rules-dev Digest, Vol 33, Issue 14
Send rules-dev mailing list submissions to
rules-dev(a)lists.jboss.org
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.jboss.org/mailman/listinfo/rules-dev
or, via email, send a message with subject or body 'help' to
rules-dev-request(a)lists.jboss.org
You can reach the person managing the list at
rules-dev-owner(a)lists.jboss.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of rules-dev digest..."
Today's Topics:
1. Problem in accesing rule constraint reference Variable
(Nikhil S. Kulkarni)
2. Re: Problem in accesing rule constraint reference Variable
(Michael Neale)
3. Problem in accesing rule constraint reference Variable
(Nikhil S. Kulkarni)
----------------------------------------------------------------------
Message: 1
Date: Wed, 16 Sep 2009 09:05:37 +0530
From: "Nikhil S. Kulkarni" <Nikhil.Kulkarni(a)mastek.com>
Subject: [rules-dev] Problem in accesing rule constraint reference
Variable
To: "rules-dev(a)lists.jboss.org" <rules-dev(a)lists.jboss.org>
Message-ID:
<697B15BDCE7BED458A324B1B4D09463D4CDDA28607(a)IND-MHP1MCL001.mastek.com>
Content-Type: text/plain; charset="us-ascii"
Hi,
I am Using Drools 5
I am facing following Issue :-
1. I am trying to access a rule Using rule flow Process but I am unable to access rule constraint reference
Variable which is easily accessible in normal .drl file
Following is the e.g. :-
In rule flow file, in Split node with XOR option, I have Written when condition in one of its Constraint
e.g. emp : Employee(age>30,salary>25000)
In this case emp is my rule reference variable. I am trying to access this emp in Action node where I have written my then Condition.
e.g. System.out.println(emp.getName());
but I am not able to get Control of same reference Variable emp. SO My Question is how to obtain same Employee object in that Action node.
Looking forward to listen from you.
Thanks & Regards,
Nikhil
MASTEK LTD.
Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20090916/e039e086/...
------------------------------
Message: 2
Date: Wed, 16 Sep 2009 13:54:13 +1000
From: Michael Neale <michael.neale(a)gmail.com>
Subject: Re: [rules-dev] Problem in accesing rule constraint reference
Variable
To: Rules Dev List <rules-dev(a)lists.jboss.org>
Message-ID:
<96ab3ced0909152054q455c225ufaa25f1572f94ce2(a)mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Probably a question for the user list - this is for the development of
drools itself.
On Wed, Sep 16, 2009 at 1:35 PM, Nikhil S. Kulkarni <
Nikhil.Kulkarni(a)mastek.com> wrote:
> Hi,
>
> I am Using Drools 5
>
>
>
> I am facing following Issue :-
>
> 1. I am trying to access a rule Using rule flow Process but I am
> unable to access rule constraint reference
>
> Variable which is easily accessible in normal .drl file
>
>
>
> Following is the e.g. :-
>
> In rule flow file, in Split node with XOR option, I have Written when
> condition in one of its Constraint
>
> e.g. *emp* : Employee(age>30,salary>25000)
>
> In this case *emp* is my rule reference variable. I am trying to access
> this *emp* in Action node where I have written my then Condition.
>
> e.g. System.out.println(emp.getName());
>
> but I am not able to get Control of same reference Variable *emp*. SO My
> Question is how to obtain same Employee object in that Action node.
>
>
>
>
>
> Looking forward to listen from you.
>
>
>
> Thanks & Regards,
>
> Nikhil
>
>
>
>
>
> MASTEK LTD.
> Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List.
> In the US, we're called MAJESCOMASTEK
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> _______________________________________________
> rules-dev mailing list
> rules-dev(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
>
--
Michael D Neale
home: www.michaelneale.net
blog: michaelneale.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20090916/2250e101/...
------------------------------
Message: 3
Date: Wed, 16 Sep 2009 19:35:51 +0530
From: "Nikhil S. Kulkarni" <Nikhil.Kulkarni(a)mastek.com>
Subject: [rules-dev] Problem in accesing rule constraint reference
Variable
To: "rules-dev(a)lists.jboss.org" <rules-dev(a)lists.jboss.org>
Message-ID:
<697B15BDCE7BED458A324B1B4D09463D4CDDAB318E(a)IND-MHP1MCL001.mastek.com>
Content-Type: text/plain; charset="us-ascii"
Hi,
I am Using Drools 5
I am facing following Issue :-
1. I am trying to access a rule Using rule flow Process but I am unable to access rule constraint reference
Variable which is easily accessible in normal .drl file
Following is the e.g. :-
In rule flow file, in Split node with XOR option, I have Written when condition in one of its Constraint
e.g. emp : Employee(age>30,salary>25000)
In this case emp is my rule reference variable. I am trying to access this emp in Action node where I have written my then Condition.
e.g. System.out.println(emp.getName());
but I am not able to get Control of same reference Variable emp. SO My Question is how to obtain same Employee object in that Action node.
Looking forward to listen from you.
Thanks & Regards,
Nikhil
MASTEK LTD.
Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20090916/8d6cb1c7/...
------------------------------
_______________________________________________
rules-dev mailing list
rules-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev
End of rules-dev Digest, Vol 33, Issue 14
*****************************************
MASTEK LTD.
Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 years, 2 months
Problem in accesing rule constraint reference Variable
by Nikhil S. Kulkarni
Hi,
I am Using Drools 5
I am facing following Issue :-
1. I am trying to access a rule Using rule flow Process but I am unable to access rule constraint reference
Variable which is easily accessible in normal .drl file
Following is the e.g. :-
In rule flow file, in Split node with XOR option, I have Written when condition in one of its Constraint
e.g. emp : Employee(age>30,salary>25000)
In this case emp is my rule reference variable. I am trying to access this emp in Action node where I have written my then Condition.
e.g. System.out.println(emp.getName());
but I am not able to get Control of same reference Variable emp. SO My Question is how to obtain same Employee object in that Action node.
Looking forward to listen from you.
Thanks & Regards,
Nikhil
MASTEK LTD.
Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 years, 2 months
Problem in accesing rule constraint reference Variable
by Nikhil S. Kulkarni
Hi,
I am Using Drools 5
I am facing following Issue :-
1. I am trying to access a rule Using rule flow Process but I am unable to access rule constraint reference
Variable which is easily accessible in normal .drl file
Following is the e.g. :-
In rule flow file, in Split node with XOR option, I have Written when condition in one of its Constraint
e.g. emp : Employee(age>30,salary>25000)
In this case emp is my rule reference variable. I am trying to access this emp in Action node where I have written my then Condition.
e.g. System.out.println(emp.getName());
but I am not able to get Control of same reference Variable emp. SO My Question is how to obtain same Employee object in that Action node.
Looking forward to listen from you.
Thanks & Regards,
Nikhil
MASTEK LTD.
Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 years, 2 months
Drools Core Error?
by nestabur
Does anyone tried to use the knowledgeAgent with statefulSessions?
I've tried to configure my rule engine obtaining unexpected behaviour.
I configure my statefulSession as follows:
wm = (ReteooStatefulSession) ((KnowledgeBaseImpl) kagent
.getKnowledgeBase()).ruleBase.newStatefulSession(
(SessionConfiguration) sessionConf, env);
ksession = new StatefulKnowledgeSessionImpl(wm, kagent.getKnowledgeBase());
And after updating the KnowledgeBase in the agent I update my ksession:
wm.setRuleBase((InternalRuleBase) ((KnowledgeBaseImpl) kagent
.getKnowledgeBase()).ruleBase);
ksession = new StatefulKnowledgeSessionImpl(wm, kagent.getKnowledgeBase());
Without using entry-points this approach works as expected, but using them
it fails after the first update throwing the error:
Exception while processing message: java.lang.NullPointerException
java.lang.NullPointerException
at
org.drools.reteoo.ReteooFactHandleFactory.newFactHandle(ReteooFactHandleFactory.java:54)
at
org.drools.common.AbstractFactHandleFactory.newFactHandle(AbstractFactHandleFactory.java:79)
at
org.drools.common.AbstractFactHandleFactory.newFactHandle(AbstractFactHandleFactory.java:66)
at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:109)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:80)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:28)
Browsing the drools core code I found the line that was throwing the
exception and tried to get the same result by implementing:
if (!((InternalRuleBase) ((KnowledgeBaseImpl)
ksession.getKnowledgeBase()).ruleBase)
.getTypeDeclaration(fact.getClass()) ==
null)
log.info (((InternalRuleBase) ((KnowledgeBaseImpl)
ksession.getKnowledgeBase()).ruleBase)
.getTypeDeclaration(fact.getClass()).getTimestampExtractor().toString());
after updating my ksession. The result was the same, again the same
exception thrown but my logger wrote:
18:01:50,232 INFO [ClassFieldExtractor class=MyPackage.MyFact
field=myTimestampField]
So I dont know why the core is throwing that exception, is that
implementation correct?, any ideas?
Thanks,
Nestor
--
View this message in context: http://www.nabble.com/Drools-Core-Error--tp25188219p25188219.html
Sent from the drools - dev mailing list archive at Nabble.com.
15 years, 2 months
Some tips for any developers on Snow Leopard (OS-X)
by Michael Neale
I recently upgrade to Snow Leopard, mostly it was an excuse to clean
out my home directory, as I had long since lost track of where and
what was on my PATH etc...
So with a fresh install, there are a few traps with Java:
1) Java 6, 64 bit only
- you can copy Java5 from Leopard over if you really need it (I have
found I am ok)
2) GWT won't work in 64 bit or java 6:
- you can start up with -d32 to make the JVM run 32 bit, and then I
have a hacked up gwt-dev-mac.jar (ping me if you need it).
3) Java 6 uses more memory, and can feel a bit slower:
- -XX:+UseCompressedOops - that can help when in 64 bit (if heap < 32 gig !).
--
Michael D Neale
home: www.michaelneale.net
blog: michaelneale.blogspot.com
15 years, 2 months
Java 6 options to aid performance
by Michael Neale
I was reading over: http://java.sun.com/javase/6/webnotes/6u14.html,
and I was wondering if anyone had tried various combinations of the
new command line tweaks while running drools benchmarks.
>From Java 6 u14 and up there are a few interesting ones:
-XX:+DoEscapeAnalysis
When hotspot is compiling a method, if it sees an object that is only
used by a single thread within the method scope, it can avoid
allocating it on the heap ! could be good for lots of small objects.
Takes a load off the GC. My intuition is that this is an automatic
version of defining a "struct" in C# (which only ever lives on the
stack) but I might be mis-reading it... (probably am).
-XX:+UseCompressedOops
If using 64 bit JVM, and heap is < 32gig, this is supposed to help -
can avoid pointers needing to be the platforms native 64bits when its
clearly overkill...
-XX:+UnlockExperimentalVMOptions -XX:+UseG1GC
This might not be experimental in a more recent version: but turns on
the G1 GC, which is a new design, could eliminate a lot of pauses...
I would love to hear if people play with these settings what the
changes are with some of the benchmarks !
--
Michael D Neale
home: www.michaelneale.net
blog: michaelneale.blogspot.com
15 years, 2 months
Running drools 4 code using drools 5 jars
by Nikhil D. Deshpande
Hi,
I have written some code using drools 4 jars.
Now as drools 5 is launched, I want to migrate my existing 'RuleBase' (drools 4) to 'KnowledgeBase'(drools 5).
1. Can I/Should I use RuleBase, PackageBuilder, ExternalSpreadSheetCompiler using drools 5 jars??
I can use these classes as they are present in drools-compiler-5.0.1.jar
Is anybody facing the same issue?
Please let me know if somebody has a solution for this.
Thanks & Regards,
Nikhil
MASTEK LTD.
Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 years, 2 months
call method getXXX or setXXX
by mjido
Hi,
When calling a method on an object the choices only showed me methods that
are not start with "get" or "set" (see ref1). I had to Add free form drl to
get around it.
And it makes methods like fields (see ref2).
This is my class:
public class TestBO
{
private String first;
private String second;
private Long testId;
public String getFirst()
{
return first;
}
public void setFirst(String s)
{
this.first = s;
}
public String getSecond()
{
return second;
}
public void setSecond(String s)
{
this.second = s;
}
public Long getTestId()
{
return testId;
}
public void setTestId(Long long1)
{
this.testId = long1;
}
public boolean getCompareFirstAndSecond()
{
return false;
}
public String getConcatFirstAndSecond()
{
return this.getFirst()+this.getSecond();
}
public void hello()
{
System.out.print("hello world \n");
}
}
Any help will be very appreciated.
http://www.nabble.com/file/p25277517/ref1.JPG ref1.JPG
http://www.nabble.com/file/p25277517/ref2.JPG ref2.JPG
--
View this message in context: http://www.nabble.com/call-method-getXXX-or-setXXX-tp25277517p25277517.html
Sent from the drools - dev mailing list archive at Nabble.com.
15 years, 2 months
WG: [rules-users] WG: Serialization of packages: InvalidClassException / serialVersionUID
by Bernd Rücker
Hey guys.
Maybe somebody of you has an idea? I cannot image that this is really a
problem, since it would invalidate the whole package deployment in govner
thing. So I guess I use the wrong approach for serialization, but I used
the code from the Ant file. Or was it addresses lately with the GA?
Thanks
Bernd
Von: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] Im Auftrag von Bernd Rücker
Gesendet: Dienstag, 1. September 2009 17:26
An: rules-users(a)lists.jboss.org
Betreff: [rules-users] WG: Serialization of packages:
InvalidClassException / serialVersionUID
The exception of the KnowledgePackage serialization (by the way, this is
described in the docs, that you can serialize the KnowledgePackages!):
/home/bruecker/workspace/1/iKS2/iks_drools_rules/drools-rules.pkg
Exception in thread "main" java.io.NotSerializableException:
org.drools.definitions.impl.KnowledgePackageImp
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
at
org.drools.util.DroolsStreamUtils.streamOut(DroolsStreamUtils.java:79)
at
org.drools.util.DroolsStreamUtils.streamOut(DroolsStreamUtils.java:61)
So this doesnt work either
(http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/ht
ml_single/index.html#d0e992):
3.2.4. Building and Deployment in Separate Processes
Both the KnowledgeBase and the KnowledgePackage are units of deployment
and serializable. This means you can have one machine do any necessary
building, requiring drools-compiler.jar, and have another machine deploy
and execute everything, needing only drools-core.jar.
Although serialization is standard Java, we present an example of how one
machine might write out the deployment unit and how another machine might
read in and use that deployment unit.
Example 3.15. Writing the KnowledgePackage to an OutputStream
ObjectOutputStream out = new ObjectOutputStream( new FileOutputStream(
fileName ) );
out.writeObject( kpkgs );
out.close();
Example 3.16. Reading the KnowledgePackage from an InputStream
ObjectInputStream in = new ObjectInputStream( new FileInputStream(
fileName ) );
// The input stream might contain an individual
// package or a collection.
@SuppressWarnings( "unchecked" )
Collection<KnowledgePackage> kpkgs =
()in.readObject( Collection<KnowledgePackage> );
in.close();
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kpkgs );
The KnowledgeBase is also serializable and some people may prefer to build
and then store the KnowledgeBase itself, instead of the Knowledge
Packages.
Drools Guvnor, our server side management system, uses this deployment
approach. After Guvnor has compiled and published serialized Knowledge
Packages on a URL, Drools can use the URL resource type to load them.
Von: Bernd Rücker [mailto:bernd.ruecker@camunda.com]
Gesendet: Dienstag, 1. September 2009 17:21
An: 'rules-users(a)lists.jboss.org'
Betreff: Serialization of packages: InvalidClassException /
serialVersionUID
Hi!
I really struggled some time with serialization issues: I want to create a
pkg and package that with the jar. >From there I want to read it during
runtime.
Easy I thought. Drools 5 way should be to serialize the KnowledgeBase,
right? At least, this is what the AntTask does.
If I try to serialize the KnowledgePackage I get an excpetion anyway:
Okay. Back to the KnowledgeBase. Serialized with Drools 5.0.0.M4 and try
to read it with 5.0.0.M5:
Caused by: java.io.InvalidClassException:
org.drools.impl.KnowledgeBaseImpl;
local class incompatible: stream classdesc serialVersionUID =
-4540376767025107954,
local class serialVersionUID = -3186110098262381425
So it seems Drools Packages are NOT compatible between minor versions?
This would be a disaster for deployment. Or do I serialize the wrong
thing? Unfortunately I didnt find anything in the docs about it.
Then I tried to do it the old Drools 4 way and serialize Package
objects, but same problem with a different serialVersionUID!
Why do these important classes dont have a serialVersionUID? Or how
should that be loaded? Must be a big issue with Govner, so I think there
must be a solution already?
Thanks for any help!
Cheers
Bernd
15 years, 2 months
Compiling drools-5 to .NET -- issue with ClassLoaders
by kpowerinfinity
Hello,
I've been trying to compile the latest version of drools to .NET for a
few days now. However, due to the classloaders structure, the classes
in the org.drools.base.extractors.* are not found by the classloader,
and the execution stops with a NoClassDefFoundError for classes in
that package.
Here's some details about the setup:
Drools version: 5.0.1
IKVM Version: 0.40.0.1
I have successfully compiled all the required libraries into a DLL
using IKVM, and a simple rule (containing a null LHS) runs
successfully, all the classes are found, and the rule engine produces
the correct output. However, when I add a condition into the LHS, it
fails because it can't find one of the classes in
/org.drools.base.extractors..*Reader/
A sample rule I am using is:
"""
package package
import rules.Customer
import rules.VoucherSeries
rule "everything free for Krishna"
when
$c : Customer( firstname == "Krishna" )
then
VoucherSeries fact0 = new VoucherSeries();
fact0.setSeriesCode( "FREE" );
insert(fact0 );
end
"""
I have verified that all the classes are present in the classloader I
am passing to the KnowledgeBuilderConfiguration. In fact, I also tried
creating a MapBasedClassLoader that contains all the missing classes
so that they can be easily found using fastFindClass. In the code
listing below, both klass and klass2 resolve to the correct class
objects.
"""
java.util.Properties p = new java.util.Properties();
p.put("drools.dialect.java.compiler", "JANINO");
java.lang.ClassLoader cl =
java.lang.Class.forName("org.drools.base.extractors.BaseLongClassFieldReader").getClassLoader();
org.drools.rule.CompositeClassLoader compositeClassLoader
= new org.drools.rule.CompositeClassLoader(cl);
org.drools.rule.MapBackedClassLoader mbcl =
getMapBackedClassLoader(cl);
compositeClassLoader.addClassLoader(mbcl);
java.lang.Class klass =
compositeClassLoader.fastFindClass("rules.Customer");
java.lang.Class klass2 =
compositeClassLoader.fastFindClass("org.drools.base.extractors.BaseObjectClassFieldReader");
java.lang.ClassLoader finalClassLoader = compositeClassLoader;
org.drools.builder.KnowledgeBuilderConfiguration kbc =
org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(p,
finalClassLoader);
"""
However, adding the DRL / PKG file, it fails with the exception:
java.lang.NoClassDefFoundError was caught
Message="org.drools.base.extractors.BaseObjectClassFieldReader"
Source="IKVM.Runtime"
StackTrace:
at IKVM.NativeCode.java.lang.ClassLoader.defineClass1(Object
thisClassLoader, String name, Byte[] b, Int32 off, Int32 len, Object
pd, String source)
at java.lang.ClassLoader.defineClass1(String , Byte[] , Int32 ,
Int32 , ProtectionDomain , String )
at java.lang.ClassLoader.defineClass(String name, Byte[] b,
Int32 off, Int32 len, ProtectionDomain protectionDomain)
at org.drools.base.ClassFieldAccessorCache.ByteArrayClassLoader.defineClass(String
name, Byte[] bytes, ProtectionDomain domain)
at org.drools.base.ClassFieldAccessorFactory.getClassFieldReader(Class
clazz, String fieldName, CacheEntry cache)
at org.drools.base.ClassFieldAccessorCache.CacheEntry.getReadAccessor(AccessorKey
key, Class cls)
at org.drools.base.ClassFieldAccessorCache.getReadAcessor(ClassFieldReader
reader)
at org.drools.base.ClassFieldAccessorStore.wire(ClassFieldReader reader)
at org.drools.base.ClassFieldAccessorStore.getReader(String
className, String fieldName, AcceptsReadAccessor target, AccessorType
accessorType)
at org.drools.base.ClassFieldAccessorStore.getReader(String
className, String fieldName, AcceptsReadAccessor target)
at org.drools.rule.builder.PatternBuilder.getFieldReadAccessor(RuleBuildContext
context, BaseDescr descr, ObjectType objectType, String fieldName,
AcceptsReadAccessor target, Boolean reportError)
at org.drools.rule.builder.PatternBuilder.build(RuleBuildContext
, Pattern , FieldConstraintDescr , AbstractCompositeConstraint )
at org.drools.rule.builder.PatternBuilder.buildConstraint(RuleBuildContext
, Pattern , Object , AbstractCompositeConstraint )
at org.drools.rule.builder.PatternBuilder.build(RuleBuildContext
context, BaseDescr descr, Pattern prefixPattern)
at org.drools.rule.builder.PatternBuilder.build(RuleBuildContext
context, BaseDescr descr)
at org.drools.rule.builder.GroupElementBuilder.build(RuleBuildContext
context, BaseDescr descr, Pattern prefixPattern)
at org.drools.rule.builder.RuleBuilder.build(RuleBuildContext context)
at org.drools.compiler.PackageBuilder.addRule(RuleDescr )
at org.drools.compiler.PackageBuilder.addPackage(PackageDescr
packageDescr)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(Resource
resource)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(Resource
resource, ResourceType type, ResourceConfiguration configuration)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(Resource
resource, ResourceType type)
at Capillary.Client.RulesEngine.RuleManager.ReadRules(String
filename) in D:\coderoot\module\DataEntryClient-DVS\SubProjects\RulesEngine\RuleManager.cs:line
116
InnerException:
I saw the code at org/drools/base/ClassFieldAccessorCache.java, and it
seems me that the Reader class for the particular type is being
defined in situ using a byte[] array, but I am unable to understand
why it can't load the class at that point.
Can anybody with a better idea of the drools classloading structure
guide me here?
Also, is the drools.NET project active now? I would post all the steps
I took for posterity.
Thanks and Regards,
Krishna.
--
http://kpowerinfinity.wordpress.com
http://www.linkedin.com/in/kpowerinfinity
15 years, 2 months