Suresh
Suresh

Reputation: 141

unable to resolve method using strict-mode in Drools 6.4

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.

Upvotes: 1

Views: 11564

Answers (2)

Tihamer
Tihamer

Reputation: 971

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.

Upvotes: 0

Ioannis Mitrolios
Ioannis Mitrolios

Reputation: 490

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.

Upvotes: 3

Related Questions