[rules-users] OSGI, classloading, and imports in KnowledgeBuilder

Lasse.Wallentin at APCC.com Lasse.Wallentin at APCC.com
Wed Aug 12 07:03:59 EDT 2009


> > Can anyone sketch a setup so that I can use Drools from within an 
Eclipse 
> > plugin?
> I've got it running. You need to make sure your classloaders are the
> right ones.
> I use the
> new PackageBuilderConfiguration(Classloader, Properties)
> 
> ctor (if you're setting CL later, Properties may fail to apply) and
> 
> new RuleBaseConfiguration(Classloader)
> 
> respectively. I guess the knowledge-based apis have matching ctors. I
> use the classloader of my project, which imports the needed drools
> namespaces. That last part may need some time, but I's doable.
> 

I have tried the following:

KnowledgeBuilderConfiguration builderConfiguration = 
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(null, 
getClass().getClassLoader());
KnowledgeBuilder kbuilder = 
KnowledgeBuilderFactory.newKnowledgeBuilder(builderConfiguration);
Resource pathResource = ResourceFactory.newClassPathResource(path, 
getClass());
kbuilder.add(pathResource, ResourceType.DTABLE, dtableconfiguration);

However it still fails ...

Does this compare to what you are doing? Are you able to do DecisionTables 
as well?

regards 

Lasse




More information about the rules-users mailing list