1

We are migrating the drools version from 5.x to 6.4 and We used all the classes and methods what we used earlier except compilation issue such as moved to new package etc.

I faced an below issue when we build DT file (xls) in maven.

[ERROR] ## Errors [Unable to Analyse Expression template != null:
[Error: unable to resolve method using strict-mode: com.svc.User.template()]
[Near : {... template != null ....}]

Note - User class is followed the Java Bean Standards.

Also I tried to disable maven dialect as below

KnowledgeBuilderConfiguration kConf = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(null,
                    classLoader);
kConf.setProperty("drools.dialect.mvel.strict", "false");
            KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(kConf);

But the same error was occurred.Please help me to fix and I am not sure, this is related to dialect or something needs to be changed DT file.

Thanks much.

Suresh
  • 131
  • 2
  • 9

2 Answers2

3

Check the getters for attribute template in class com.svc.User. It must follow the convention

public {OBJECT_TYPE} getTemplate(){ return template; }

Errors of this type usually means that it can not find a method with this name (template() in this case) which usually means there is some problem with the getter of the attibute.

  • You said you build an .xls file. I guess you have imported the Class and I also guess you have checked the getters. Since you have mentioned the versions the Drools knowledge base is deprecated. Maybe there is some conflict: [link] (http://stackoverflow.com/questions/23784652/drools-knowledgebase-deprecated) – Ioannis Mitrolios Sep 02 '16 at 18:29
  • 1
    Yes ... I have imported that class in xls and check that template property != null . I have checked the drools-core jar 6.4.Final, yup the class was not there and thery are restructured everything... but if you check that in drools-knowledge 6.4.Final api , the KnowledgeBase class is there.I adedd both as maven dependencies in pom. I knew they introduced new api called Kie. – Suresh Sep 03 '16 at 05:17
  • Yes it is deprecated but still supported. OK can you post the table of the .xls with the error? Especially the condition that checks the template. – Ioannis Mitrolios Sep 03 '16 at 08:04
  • I changed all the old class to new kie classes. Now i am building the kjar via the kie maven plugin.I faced a compilation issue like the same error as mentioned..My condition in DT file is template in ($param) and I passed a single value "DEMO" but I got exception like Unable to Analyse Expression template == DEMO.The problem is single value is not taking in 'in' clause as param.If I run the spreadsheet compiler , the double quote is not appending value with DEMO.Please help me to resolve this ... Thanks much – Suresh Sep 06 '16 at 16:37
  • If template is String then try this condition: template in "{$param}" or this: template in "$param" – Ioannis Mitrolios Sep 06 '16 at 21:53
  • Thanks for your reply.The problem is when I pass single value , double quotes is not appending but when pass more than two values quotes is appending both values like "DEMO" ,"SAM" – Suresh Sep 07 '16 at 04:01
  • What object is template? It is a String I guess. And if you want to check for one single value why do you use in? You should use: template == "$param" – Ioannis Mitrolios Sep 07 '16 at 07:57
  • I have multiple rows and some of the rows contains single and some of the rows contains two values.template property is contains in User POJO class with setters and getters. I am not sure how to resolve this and It's compiling in drools 5.x. Please help...Thanks – Suresh Sep 07 '16 at 09:02
0

I ran into the same error, but my problem (that I eventually solved) was that I had declared my variable (in your case "template") as a static variable. So the get method was also static (I had used Eclipse's automatic getter and setter generation). As soon as I got rid of the static modifier, my rules worked fine.

Tihamer
  • 935
  • 10
  • 8