<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt">Hi guys,<br> I have a question regarding the import function feature in Drools 5.1.0M. <br><br> I am reading the Drools <span class="yshortcuts" id="lw_1257218127_0">JBoss</span>
Rules 5.0 book Developer's guide by Michal Bali and tried one of the
examples but somehow I couldn't get my rules work with the method that
has varargs. <br><br>Here's what I have (copied from page 123):<br><br>public class ValidationHelper {<br> public static void error (RuleContext kcontext, Object... context) {<br> KnowledgeRuntime knowledgeRuntime = kcontext.getKnowledgeRuntime();<br> ValidationReport validationReport = (ValidationReport)knowledgeRuntime.getGlobal("validationReport");<br> ReportFactory reportFactory = (ReportFactory) knowledgeRuntime.getGlobal("reportFactory");<br><br> kcontext.insertLogical(reportFactory.createMessage(<br> Message.Type.ERROR, kcontext.getRule().getName(),<br> context));<br> }<br>}<br><br><br>then in my drools file (copied from page 42): <br>i have<br><br>import org.drools.runtime.rule.RuleContext;<br>import
function ValidationHelper.error;<br>...<br>rule test<br>when<br> #condition<br> then<br> error(drools)<br><br><br>but when I ran the test, I got error message:<br><br>Exception
in thread "main" org.drools.runtime.rule.ConsequenceException: [Error:
unable to resolve method:
ValidationHelper.error(org.drools.base.DefaultKnowledgeHelper)
[arglength=1]]<br><br>If I remove the parameter Object... context, then
everything worked. But I do need the varargs here because I need my
error message to be more specific.<br><br>Did anyone else encounter the same problems?<br><br><br>thanks!</div><br>
</body></html>