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(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On
Behalf Of rules-users-request(a)lists.jboss.org
Sent: Wednesday, June 16, 2010 8:25 AM
To: rules-users(a)lists.jboss.org
Subject: rules-users Digest, Vol 43, Issue 89
Send rules-users mailing list submissions to
rules-users(a)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(a)lists.jboss.org
You can reach the person managing the list at
rules-users-owner(a)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(a)gmail.com>
Subject: Re: [rules-users] Dynamic Rule Loading
To: Rules Users List <rules-users(a)lists.jboss.org>
Message-ID:
<AANLkTil7CJpWIhO_eodIWM7vpgIS8NDzPyAP2Hx67JqO(a)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(a)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(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Esteban Aliverti