Hi,
I am upgrading our application from Drools 4.0.7 to 5.0.0.SNAPSHOT
(using JDK 1.6)
I have noticed that RuleServiceProvider.createRuleExecutionSet requires
a org.drools.rule.Package instead of a KnowledgePackage. If I use a
KnowledgePackage the following exception is thrown:
RuleException(javax.rules.admin.RuleExecutionSetCreateException:
Incoming AST object must be an org.drools.rule.Package. Was class
org.drools.definitions.impl.KnowledgePackageImp), root cause(null)
at
org.drools.jsr94.rules.admin.LocalRuleExecutionSetProviderImpl.createRul
eExecutionSet(LocalRuleExecutionSetProviderImpl.java:211)
To get rid of the exception I have to cast
org.drools.definitions.impl.KnowledgePackageImp to KnowledgePackage.
Maybe
org.drools.jsr94.rules.admin.LocalRuleExecutionSetProviderImpl.createRul
eExecutionSet should also look for a KnowledgePackage?
Am I doing something wrong?
Below is a code snippet of what I am doing:
KnowledgePackage binPkg = (KnowledgePackage)
brmsRepository.loadRuleSet(uuid).getCompiledRuleSetObject();
// Drools JSR-94 requires a org.drools.rule.Package
org.drools.rule.Package pkg =
((org.drools.definitions.impl.KnowledgePackageImp) binPkg).pkg;
String RULE_SERVICE_PROVIDER = "http://drools.org/";
String RULE_URI = "MyPackage";
RuleServiceProviderManager.registerRuleServiceProvider(RULE_SERVICE_PROV
IDER, RuleServiceProviderImpl.class);
RuleServiceProvider ruleServiceProvider =
RuleServiceProviderManager.getRuleServiceProvider(RULE_SERVICE_PROVIDER)
;
RuleAdministrator ruleAdministrator =
ruleServiceProvider.getRuleAdministrator();
LocalRuleExecutionSetProvider ruleSetProvider =
ruleAdministrator.getLocalRuleExecutionSetProvider(null);
Here an exception is thrown for a KnowledgePackage
// Drools JSR-94 requires a org.drools.rule.Package - Exception
thrown if it is a KnowledgePackage
RuleExecutionSet ruleExecutionSet =
ruleSetProvider.createRuleExecutionSet(pkg, null);
Etc...
Thanks,
Len
Len Carlsen
Student Systems
The University of British Columbia