[jboss-jira] [JBoss JIRA] (DROOLS-1070) FactType object instantiated outside drools no longer match rules in 6.3.0.Final
Mario Fusco (JIRA)
issues at jboss.org
Mon Apr 11 12:22:00 EDT 2016
[ https://issues.jboss.org/browse/DROOLS-1070?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mario Fusco resolved DROOLS-1070.
---------------------------------
Resolution: Rejected
KieBase.getFactType should be used only to retrieve beans defined as declared types and not plain java classes. Indeed trying to reproduce your use case I'm getting this exception https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/core/definitions/impl/KnowledgePackageImpl.java#L635 and I'm honestly wondering how you're not getting the same.
That said you can easily achieve this result using the ClassLoader provided by the KieContainer like it follows:
{code}
Object testObject = kieContainer.getClassLoader().loadClass("my.package.MyClass").newInstance();
{code}
> FactType object instantiated outside drools no longer match rules in 6.3.0.Final
> --------------------------------------------------------------------------------
>
> Key: DROOLS-1070
> URL: https://issues.jboss.org/browse/DROOLS-1070
> Project: Drools
> Issue Type: Bug
> Components: core engine
> Affects Versions: 6.3.0.Final
> Environment: Java 8 (1.8.0_72)
> Reporter: Jogchem de Groot
> Assignee: Mario Fusco
>
> There's a problem of regression between the drools 6.2.0.Final and 6.3.0.Final releases:
> In 6.2.0.Final the following was possible:
> - You could create a FactType (for example a Data Object in the workbench) in your knowledge base
> - From your application code, after loading the knowledge base. You could obtain the specific FactType from the knowledge base, get the class and instantiate a new instance of that class, effectively being a new instance of the FactType.
> - This new instance of the FactType could then be inserted into a drools session for the knowledge base and would be succesfully matched by rules that match the FactType as defined in the knowledge base.
> In 6.3.0.Final these rules would no longer be activated as the new FactType instance would be loaded by a different class loader (and thus is a different class) than the FactType class that the rules are trying to match.
> Therefore: in 6.3.0.Final it's no longer possible to define your business objects in your rule base, but have them populated and supplied outside of the rule session (in your application code).
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jboss-jira
mailing list