[rules-users] Dynamic rule loading

Fnu Mahalakshmi FMahalakshmi at nyx.com
Wed Jun 16 08:33:48 EDT 2010


Hi,
Yes I added the drools-compiler as a dependency.
I have added all the required jars to my classpath.
Any other error???
Thanks
M

-----Original Message-----
From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of rules-users-request at lists.jboss.org
Sent: Wednesday, June 16, 2010 8:25 AM
To: rules-users at lists.jboss.org
Subject: rules-users Digest, Vol 43, Issue 89

Send rules-users mailing list submissions to
	rules-users at lists.jboss.org

To subscribe or unsubscribe via the World Wide Web, visit
	https://lists.jboss.org/mailman/listinfo/rules-users
or, via email, send a message with subject or body 'help' to
	rules-users-request at lists.jboss.org

You can reach the person managing the list at
	rules-users-owner at lists.jboss.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of rules-users digest..."


Today's Topics:

   1. Re: Dynamic Rule Loading (Esteban Aliverti)
   2. Re: rule error (Esteban Aliverti)


----------------------------------------------------------------------

Message: 1
Date: Wed, 16 Jun 2010 09:21:13 -0300
From: Esteban Aliverti <esteban.aliverti at gmail.com>
Subject: Re: [rules-users] Dynamic Rule Loading
To: Rules Users List <rules-users at lists.jboss.org>
Message-ID:
	<AANLkTil7CJpWIhO_eodIWM7vpgIS8NDzPyAP2Hx67JqO at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Are you including drools-compiler as a dependency?

On Tue, Jun 15, 2010 at 5:28 PM, Fnu Mahalakshmi <FMahalakshmi at nyx.com>wrote:

> Hi,
>
> I was trying to use knowledge builder package for dynamic loading of the
> rule files. Getting major errors.
>
> My knowledge builder basically adds the rule resources from the
> change-set.xml file which I have in my project directory.
>
> I am using the knowledge agent and knowledge base to add all the packages
> loaded from my change-set xml file.
>
> Am I wrong somewhere???
>
> My code is as follows:
>
>
>    private KnowledgeBase loadRules(String[]  rules) throws Exception{
>
> KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
>          kbuilder.add( ResourceFactory.newClassPathResource(
> "/change-set.xml", getClass() ),
>                        ResourceType.CHANGE_SET );
>          if ( kbuilder.hasErrors() ) {
>              System.err.println( kbuilder.getErrors().toString() );
>          }
>          KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent(
> "MyAgent" );
>          kagent.applyChangeSet(
> ResourceFactory.newClassPathResource("/change-set.xml", getClass()));
>          KnowledgeBase kbase = kagent.getKnowledgeBase();
>          kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
>
>          return kbase;
>    }
>
> my change-set.xml is as follows:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <change-set xmlns='http://drools.org/drools-5.0/change-set'
>             xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
>             xs:schemaLocation='drools-change-set-5.0.xsd' >
>  <add>
>       <resource source='src/main/rules/' type='DRL' />
>   </add>
>  </change-set>
>
> I am getting the following error stack when I run:
>
> Exception in thread "main" org.drools.ProviderInitializationException:
> Provider org.drools.builder.impl.KnowledgeBuilderProviderImpl could not be
> set.
>        at
> org.drools.builder.KnowledgeBuilderFactory.loadProvider(KnowledgeBuilderFactory.java:111)
>        at
> org.drools.builder.KnowledgeBuilderFactory.getKnowledgeBuilderProvider(KnowledgeBuilderFactory.java:101)
>        at
> org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder(KnowledgeBuilderFactory.java:29)
>        at com.org.RuleRunner.loadRules(RuleRunner.java:58)
>        at com.org.RuleRunner.runStatelessRules(RuleRunner.java:127)
>        at com.org.RulesTest.main(RulesTest.java:40)
> Caused by: java.lang.ClassNotFoundException:
> org.drools.builder.impl.KnowledgeBuilderProviderImpl
>        at java.net.URLClassLoader$1.run(Unknown Source)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at java.net.URLClassLoader.findClass(Unknown Source)
>        at java.lang.ClassLoader.loadClass(Unknown Source)
>        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>        at java.lang.ClassLoader.loadClass(Unknown Source)
>        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
>        at java.lang.Class.forName0(Native Method)
>        at java.lang.Class.forName(Unknown Source)
>        at
> org.drools.builder.KnowledgeBuilderFactory.loadProvider(KnowledgeBuilderFactory.java:108)
>        ... 5 more
>
>
> The error comes exactly at the start where I call knowledge builder.
> Please help!!
>
> Thanks
> M
>
> Please consider the environment before printing this email.
>
> Visit our website at http://www.nyse.com
>
> ****************************************************
>
> Note:  The information contained in this message and any attachment to it
> is privileged, confidential and protected from disclosure.  If the reader of
> this message is not the intended recipient, or an employee or agent
> responsible for delivering this message to the intended recipient, you are
> hereby notified that any dissemination, distribution or copying of this
> communication is strictly prohibited.  If you have received this
> communication in error, please notify the sender immediately by replying to
> the message, and please delete it from your system.  Thank you.  NYSE
> Euronext.
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100616/83036389/attachment-0001.html 

------------------------------

Message: 2
Date: Wed, 16 Jun 2010 09:24:05 -0300
From: Esteban Aliverti <esteban.aliverti at gmail.com>
Subject: Re: [rules-users] rule error
To: Rules Users List <rules-users at lists.jboss.org>
Message-ID:
	<AANLkTin7WWH2t8YETZvExSa9bGHwh7lqBvUYZgRobVIW at mail.gmail.com>
Content-Type: text/plain; charset="windows-1252"

I recommend you to read the manual first.

2010/6/16 Giovanni Motta <mottagio at gmail.com>

> You have 2 options here:
> status == ?yes" *||* status == "no"
> status == ?yes" *||* == "no"
>
> 'or' connector is not applied on constraints, but on patterns.
>
> Regards
>
> 2010/6/16 Fnu Mahalakshmi <FMahalakshmi at nyx.com>
>
>>  Hi,
>>
>>
>>
>> I want to just depict ?&&? and ?or? in my rules and did as follows:
>>
>>
>>
>> *rule* "Update value?
>>
>> *no-loop* *true*
>>
>>       *when*
>>
>>             $y :Y(name != "")
>>
>>             $x: X(status != "")
>>
>>             $z : Z( y == $y, x == $X,(status == ?yes" *or* status == "no"
>> ))
>>
>>       *then*
>>
>>             *modify*($z){};
>>
>>
>>
>> end
>>
>>
>>
>> The above does not work. Is it not valid to write as above??
>>
>> How else can I depict ?or? ? relation?
>>
>> *rule* "Update value"
>>
>> *no-loop* *true*
>>
>>       *when*
>>
>>             $y :Y(name != "")
>>
>>             $x: X(status != "")
>>
>>             $z : Z( y == $y, x == $X,(status == ?yes" *, *status == "no"
>> ))
>>
>>       *then*
>>
>>             *modify*($z){
>>
>> setOutput($z)};
>>
>>
>>
>> end
>>
>>
>>
>>
>>
>> even this does not work.
>>
>>
>>
>> I also want to add all the values specific to this condition and just
>> print them out in my output file.
>>
>> So I tried adding it to a list (which is done by setOutput().
>>
>> But here I keep getting multiple entries for the same value.
>>
>> For eg. {a,b,c } //are instances of type z
>>
>> They keep getting added again and again. Should it not process input only
>> once????
>>
>>
>>
>>
>>
>> Please help.
>>
>>
>>
>> Thank you
>>
>> m
>>
>> ------------------------------
>>
>> *Please consider the environment before printing this email.*
>>
>> *Visit our website at http://www.nyse.com
>> *****************************************************************************
>>
>> Note: The information contained in this message and any attachment to it
>> is privileged, confidential and protected from disclosure. If the reader of
>> this message is not the intended recipient, or an employee or agent
>> responsible for delivering this message to the intended recipient, you are
>> hereby notified that any dissemination, distribution or copying of this
>> communication is strictly prohibited. If you have received this
>> communication in error, please notify the sender immediately by replying to
>> the message, and please delete it from your system. Thank you. NYSE
>> Euronext. *
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100616/e0eb8962/attachment.html 

------------------------------

_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


End of rules-users Digest, Vol 43, Issue 89
*******************************************
Please consider the environment before printing this email.

Visit our website at http://www.nyse.com

****************************************************

Note:  The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure.  If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.  If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system.  Thank you.  NYSE Euronext.





More information about the rules-users mailing list