[rules-users] adding process to an empty rule base

hypnosat7 ablarbi at yahoo.fr
Fri Jul 27 13:18:42 EDT 2007


If I do like this, it works :

PackageBuilder builder = new PackageBuilder();
Reader drlReader = new
InputStreamReader(getClass().getResourceAsStream("/emptyPackage.drl"));
builder.addPackageFromDrl(drlReader);
builder.addRuleFlow(ruleFlow);
Package pkgRuleFlow = builder.getPackage();
ruleBase.addPackage(pkgRuleFlow);

In the emptyPackage.drl file this no rules, but it seems to be impossible to
have a rule base with only a rule flow. I hope I'm wrong :)



hypnosat7 wrote:
> 
> thanks, it works but now I have this :
> Caused by: java.lang.NullPointerException
> 	at
> org.drools.compiler.PackageBuilder.addRuleFlowsToPackage(PackageBuilder.java:469)
> 	at org.drools.compiler.PackageBuilder.getPackage(PackageBuilder.java:449)
> 
> 
> 
> Kris Verlaenen wrote:
>> 
>> This error is caused by a mismatch between the version of the mvel
>> library 
>> you are using and the version that is expected by drools.
>> Drools 4.0.0 is expecting mvel14-1.2rc1.jar.  Previous versions of drools 
>> are probably based on older versions of mvel.
>> Might also be caused by having multiple versions of mvel in your
>> classpath.
>> 
>> Kris
>> 
>> ----- Original Message ----- 
>> From: "hypnosat7" <ablarbi at yahoo.fr>
>> To: <rules-users at lists.jboss.org>
>> Sent: Friday, July 27, 2007 5:30 PM
>> Subject: Re: [rules-users] adding process to an empty rule base
>> 
>> 
>>>
>>>
>>> I try this:
>>> ...
>>> InputStream stream =
>>> getClass().getResourceAsStream("/rules/demoRuleFlow.rfm");
>>> Reader ruleFlowReader = new InputStreamReader(stream);
>>> ruleEngine.setRuleFlow(ruleFlowReader);
>>> ..
>>>
>>> PackageBuilder builder = new PackageBuilder();
>>> builder.addRuleFlow(ruleFlow);
>>> Package pkgRuleFlow = builder.getPackage();
>>> ruleBase.addPackage(pkgRuleFlow);
>>>
>>> but I have this error:
>>> Caused by: java.lang.NoSuchMethodError:
>>> org.mvel.optimizers.OptimizerFactory.setDefaultOptimizer(Ljava/lang/String;)V
>>> at
>>> org.drools.rule.builder.dialect.mvel.MVELDialect.init(MVELDialect.java:132)
>>> at org.drools.compiler.DialectRegistry.initAll(DialectRegistry.java:49)
>>> at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:139)
>>> at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:88)
>>>
>>>
>>>
>>> Kris Verlaenen wrote:
>>>>
>>>> Yes, that is possible, but you should also add the (generated) package
>>>> of
>>>> your PackageBuilder.
>>>>
>>>> But this process is actually much simpler when using the ProcessBuilder
>>>> exclusively.
>>>> It should look something like this:
>>>>
>>>> PackageBuilder builder = new PackageBuilder();
>>>> // add your rules (if any)
>>>> builder.addPackageFromDrl( ... );
>>>> // add your processes (if any)
>>>> builder.addRuleFlow( ... );
>>>> // add Package to ruleBase
>>>> Package pkg = builder.getPackage(); // this includes all the rules and
>>>> processes
>>>> ruleBase.addPackage( pkg );
>>>>
>>>> Kris
>>>>
>>>> ----- Original Message ----- 
>>>> From: "hypnosat7" <ablarbi at yahoo.fr>
>>>> To: <rules-users at lists.jboss.org>
>>>> Sent: Friday, July 27, 2007 3:59 PM
>>>> Subject: [rules-users] adding process to an empty rule base
>>>>
>>>>
>>>>>
>>>>> Is it possible to set the rule flow in my rule base before adding rule
>>>>> packages :
>>>>>
>>>>> ruleBase = RuleBaseFactory.newRuleBase();
>>>>> org.drools.compiler.ProcessBuilder processBuilder = new
>>>>> ProcessBuilder(new
>>>>> PackageBuilder());
>>>>> processBuilder.addProcessFromFile(ruleFlow);
>>>>> ruleBase.addProcess(processBuilder.getProcesses()[0]);
>>>>>
>>>>> thanks
>>>>> -- 
>>>>> View this message in context:
>>>>> http://www.nabble.com/adding-process-to-an-empty-rule-base-tf4157978.html#a11829714
>>>>> Sent from the drools - user mailing list archive at Nabble.com.
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>>>
>>>>
>>>
>>> -- 
>>> View this message in context: 
>>> http://www.nabble.com/adding-process-to-an-empty-rule-base-tf4157978.html#a11831502
>>> Sent from the drools - user mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> 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
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/adding-process-to-an-empty-rule-base-tf4157978.html#a11833321
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list