[jboss-jira] [JBoss JIRA] (JBRULES-3562) Drools cannot resolve functions when argument is a fact type

RH Bugzilla Integration (JIRA) jira-events at lists.jboss.org
Fri Sep 28 09:54:03 EDT 2012


    [ https://issues.jboss.org/browse/JBRULES-3562?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12722543#comment-12722543 ] 

RH Bugzilla Integration commented on JBRULES-3562:
--------------------------------------------------

Toni Rikkola <trikkola at redhat.com> made a comment on [bug 851310|https://bugzilla.redhat.com/show_bug.cgi?id=851310]

I managed to isolate what Guvnor does in this unit test:

 @Test
    public void testMvelFunctionWithDeclaredTypeArg2() throws IOException, DroolsParserException {

        String function = "function String getFieldValue(Bean bean) {" +
                "   return bean.getField();" +
                "}";
        String declaredFactType = "declare Bean \n" +
                "   field : String \n" +
                "end \n";
        String rule = "rule R2 \n" +
                "dialect 'mvel'\n" +
                "when \n" +
                "   $bean : Bean( ) \n" +
                "then \n" +
                "   System.out.println( getFieldValue($bean) ); \n" +
                "end";

        PackageBuilder packageBuilder = new PackageBuilder();
        packageBuilder.addPackageFromDrl(new StringReader(declaredFactType));
        packageBuilder.addPackageFromDrl(new StringReader(function));
        packageBuilder.addPackageFromDrl(new StringReader(rule));

        for (KnowledgeBuilderError error : packageBuilder.getErrors()) {
            System.out.println("ERROR:");
            System.out.println(error.getMessage());
        }
        assertFalse(packageBuilder.hasErrors());
    }

Currently the test fails to pass. If the dialect for the Rule R2 is removed it works.

There are few solutions: 

#1 We remove the PackageBuilder from Guvnor and replace it with KnowledgeBuilder. This is a not a small task and will take a week or more.

#2 We make PackageBuilder work with how Guvnor is using it. 

Mario is taking a look at #2. Hopefully there is an easy fix.
                
> Drools cannot resolve functions when argument is a fact type
> ------------------------------------------------------------
>
>                 Key: JBRULES-3562
>                 URL: https://issues.jboss.org/browse/JBRULES-3562
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-compiler
>    Affects Versions: 5.3.0.Final
>         Environment: Linux Ubuntu, JBoss 5.1.0
>            Reporter: Nedo Nedic
>            Assignee: Mario Fusco
>             Fix For: 5.5.0.Beta1
>
>
> Note that this only fails when MVEL dialect is used with functions using non-primitive argument types (for an instance using
> fact types arguments).
> This error appeared when we migrated from Drools 5.0.1.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list