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