drools - Unable to Analyse Expression

不想你离开。 提交于 2021-02-08 10:55:54

问题


I have defined some rules in DRL file, and its my first program of creating a drl file. I am getting the error "unable to analyse expression".Here is my code:

package rules

import com.sample.Applicant.appli;

rule "Is of valid age"

when

    $a : appli ( age < 18 ) // appli is my class name
                            // age is a variable in that class

then

    $a.setValid( false ); // setValid is a method of appli

end

and getting the error:

Unable to Analyse Expression age < 18:

[Error: unable to resolve method using strict-mode: com.sample.Applicant$appli.age()]

[Near : {... age < 18 ....}]

         ^
[Line: 16, Column: 4] : [Rule name='Is of valid age']

回答1:


Make sure in the class appli, age is either public or has a public getAge() method.




回答2:


Even I was getting similar error 'Unable to Analyse Expression....' while validating a DRL file in Drools Workbench 6.4.0 Final. I checked Data Object, its fields, access specifier of the setters and getters. All seemed OK. Then I saved my data object and came back to DRL file and did validating. Suddenly the above error was gone and I saw message 'Successfully Validated'. My mistake was though I had created the Data Object in Drools Workbench, I had forgotten to save it by clicking 'Save' button.

So I would suggest you, if you are 100% sure that your Data Object and DRL files are correct, save these first and then validate DRL file again.



来源:https://stackoverflow.com/questions/18045403/drools-unable-to-analyse-expression

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!