[rules-users] xls decisiontable -> unable to resolve method using strict-mode

Olle Martensson olle.martensson at digitalroute.com
Mon Jan 9 08:58:08 EST 2012


I've been trying to set MVEL strict mode to false to see if it works better but it does not seem to take:


PackageBuilderConfiguration pconf = new PackageBuilderConfiguration(context.getClassLoader());

        ((JavaDialectConfiguration)

        pconf.getDialectConfiguration("java")).setCompiler(JavaDialectConfiguration.ECLIPSE);

        ((JavaDialectConfiguration)

        pconf.getDialectConfiguration("java")).setJavaLanguageLevel("1.5");

        ((MVELDialectConfiguration)

pconf.getDialectConfiguration("mvel")).setStrict(false);

        ((MVELDialectConfiguration)

pconf.getDialectConfiguration("mvel")).setLangLevel(5);

From: olle martensson <olle.martensson at digitalroute.com<mailto:olle.martensson at digitalroute.com>>
Reply-To: Rules Users List <rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>>
Date: Mon, 9 Jan 2012 14:18:42 +0100
To: Rules Users List <rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>>
Subject: Re: [rules-users] xls decisiontable -> unable to resolve method using strict-mode

Ignore the last post, It was a silly mistake on my part .. sorry about that.
It makes no difference if I use run the DTABLE without KnowledgeAgent:

Jan 9 14:08:19: Unable to Analyse Expression request == "/":
Jan 9 14:08:19: [Error: unable to resolve method using strict-mode: ultra.Default.ultra.MYHTTPD.request()]
Jan 9 14:08:19: [Near : {... request == "/" ....}]
Jan 9 14:08:19:              ^
Jan 9 14:08:19: [Line: 7, Column: 10]

Drools tries to resolve the property request with a call to ultra.Default.ultra.MYHTTPD.request() when it should look for ultra.Default.ultra.MYHTTPD.getRequest().

[cid:C7EB7185-C8D8-4A4E-B4D3-2CFC16ED2368]


From: olle martensson <olle.martensson at digitalroute.com<mailto:olle.martensson at digitalroute.com>>
Reply-To: Rules Users List <rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>>
Date: Mon, 9 Jan 2012 13:25:10 +0100
To: Rules Users List <rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>>
Subject: Re: [rules-users] xls decisiontable -> unable to resolve method using strict-mode

Thanks for your answer.

I have now tried to load the XLS without the KnowledgeAgent(see createKnowledgeBase() below).
This time I got class loading problems( see stack trace below).
This only happens when I load a XLS decision table, If I load a DRL rules file it runs fine without classloading issues.
I use a custom classloader that is configured with the KnowledgeBaseConfiguration, I can see that drools is trying to load the rule classes from the custom classloader when I run DTABLE but not when I run DRL.
>From the stacktrace it seems as if it's using CompositeClassLoader though.

### STACKTRACE ###

java.lang.ClassNotFoundException: Unable to load classA_rules_test.Rule_print_the_incoming_query_9
    at org.drools.util.CompositeClassLoader.loadClass:110
    at org.drools.rule.JavaDialectRuntimeData$PackageClassLoader.loadClass:540
    at java.lang.ClassLoader.loadClass:247
    at A_rules_test.Rule_print_the_incoming_query_9DefaultConsequenceInvoker.evaluate
    at org.drools.common.DefaultAgenda.fireActivation:1091
    at org.drools.common.DefaultAgenda.fireNextItem:1029
    at org.drools.common.DefaultAgenda.fireAllRules:1251
    at org.drools.common.AbstractWorkingMemory.fireAllRules:708
    at org.drools.common.AbstractWorkingMemory.fireAllRules:672
    at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules:218

### CREATION OF KNOWLEDGEBASE ###


private void createKnowledgeBase()

    {

        KnowledgeBaseConfiguration kBaseConfig = KnowledgeBaseFactory

                .newKnowledgeBaseConfiguration(null, context.getClassLoader());

        kBaseConfig.setOption(EventProcessingOption.STREAM);

       //kBaseConfig.setOption(MultithreadEvaluationOption.YES);

       //kBaseConfig.setOption(MaxThreadsOption.get(Runtime.getRuntime().availableProcessors() * 2));

        KnowledgeBase kBase = KnowledgeBaseFactory

                .newKnowledgeBase(kBaseConfig);


        KnowledgeBuilderConfiguration bconf = KnowledgeBuilderFactory

                .newKnowledgeBuilderConfiguration(null,

                        context.getClassLoader());

        bconf.setProperty("drools.dialect.java.compiler", "ECLIPSE");

        bconf.setProperty("drools.dialect.java.lngLevel", "1.6");



        DecisionTableConfiguration dtableconfiguration =

        KnowledgeBuilderFactory.newDecisionTableConfiguration();

        dtableconfiguration.setInputType( DecisionTableInputType.XLS );




        PackageBuilderConfiguration pconf = (PackageBuilderConfiguration) bconf;

        pconf.setClassLoaderCacheEnabled(true);



        MVELDialectConfiguration conf = (MVELDialectConfiguration)pconf.getDialectConfiguration("mvel");

        conf.setStrict(false);



        String compilerDumpDir = context.getCompilerDumpDir();

        if (compilerDumpDir != null && !compilerDumpDir.isEmpty())

        {

            pconf.setDumpDir(new File(compilerDumpDir));

        }



        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(kBase, bconf);



        kbuilder.add(ResourceFactory.newFileResource("/tmp/templatetest.xls"),

                      ResourceType.DTABLE,

                      dtableconfiguration);

    }



From: Michael Anstis <michael.anstis at gmail.com<mailto:michael.anstis at gmail.com>>
Reply-To: Rules Users List <rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>>
Date: Mon, 9 Jan 2012 09:18:51 +0100
To: Rules Users List <rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>>
Subject: Re: [rules-users] xls decisiontable -> unable to resolve method using strict-mode

Have you tried load the XLS into a KnowledgeBase without using a KnowledgeAgent?

Trying to narrow down where the issue might be will help (everyone) tremendously.

On 5 January 2012 16:40, ollem <olle.martensson at digitalroute.com<mailto:olle.martensson at digitalroute.com>> wrote:
Hello!

I'm using a knowledgeagent to point out a changeset XML which contains the
following DTABLE:

...
<resource source='file:/../templatetest.xls' type='DTABLE' />
...

when I compile I get the following error:

Unable to Analyse Expression request == "/":
[Error: unable to resolve method using strict-mode:
ultra.Default.ultra.MYHTTPD.request()]
[Near : {... request == "/" ....}]
            ^
[Line: 7, Column: 10] : [Rule name='print the incoming query_9']

The weird this is that MYHTTPD class is a javabean and contains getRequest
and setRequest methods.
notice that it tries a no getter method
ultra.Default.ultra.MYHTTPD.request().
If I do the same logic from a normal DRL rules file it works fine.
MYHTTPD is generated so I cannot past the source here, but it's correct and
as I mentioned working in DRL files.

this is how the XSL file looks like:

RuleSet A rules test
Import  ultra.Default.ultra.MYHTTPD

RuleTable    print the incoming query
CONDITION        ACTION
MYHTTPD
request  System.out.println($param);
Matcher  Logger
/                "webserver root"

Anybody who knows what this is about?

Thanks // Olle






--
View this message in context: http://drools.46999.n3.nabble.com/xls-decisiontable-unable-to-resolve-method-using-strict-mode-tp3635460p3635460.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120109/9e597081/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: C7EB7185-C8D8-4A4E-B4D3-2CFC16ED2368.png
Type: image/png
Size: 89375 bytes
Desc: C7EB7185-C8D8-4A4E-B4D3-2CFC16ED2368.png
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20120109/9e597081/attachment.png 


More information about the rules-users mailing list