[rules-users] Re: ClassLoader Problem
Yann Massard
y_massar at informatik.uni-kl.de
Mon Oct 20 04:26:13 EDT 2008
Hi John,
thank you, but this is not the problem. The PluginClassLoader loads the
classes as expected. Everything works fine until I add statements using
the plugin's classes on the RHS of the rule (see comments in Sample.drl).
Yann
John wrote:
> Yann,
>
> You need to add your com/sample/* classes to the classpath of your
> PluginClassLoader, or configure that ClassLoader to use a parent that
> has those classes on its classpath.
>
> John
>
> Yann Massard wrote:
>> Hi,
>>
>> I am using version 4.0.7 of Drools.
>>
>> I am trying to load facts with a particular ClassLoader and compiling
>> the rules using the same ClassLoader:
>>
>> ------
>> Reader source = new FileReader("plugin/Sample.drl");
>> ClassLoader pluginClassLoader = new PluginClassLoader();
>>
>> Thread.currentThread().setContextClassLoader( pluginClassLoader );
>> PackageBuilder builder = new PackageBuilder(new
>> PackageBuilderConfiguration(pluginClassLoader));
>>
>> builder.addPackageFromDrl(source);
>> Package pkg = builder.getPackage();
>>
>> RuleBase ruleBase = RuleBaseFactory.newRuleBase();
>> ruleBase.addPackage(pkg);
>> ------
>>
>> This works fine for usage of the fact types in the LHS of rules and for
>> field extraction.
>> But when I add a method invocation or an update statement on a fact to
>> the RHS of a rule I get a rule compilation error:
>>
>> -------
>> org.drools.rule.InvalidRulePackage: Rule Compilation error : [Rule
>> name=Hello World, agendaGroup=MAIN, salience=0, no-loop=false]
>> com/sample/Rule_Hello_World_0.java (6:267) : plugin.Message cannot be
>> resolved to a type
>> -------
>>
>> I have reduced the problem to a minimal complexity (see attachments).
>> Any ideas?
>>
>> By the way: do I really need to set both the ClassLoader in the
>> PackageBuilderConfiguration AND the ContextClassLoader (as described in
>> http://blog.athico.com/2006/12/dynamically-generated-class-beans-as.html)?
>>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
More information about the rules-users
mailing list