Hi,
i have some problems with custom functions and types.
I m using Drools 5.0 and Eclipse 3.4.2 (have to use these eclipse
version, so my decision was to use the drools beta).
I declared a type in my rule file like :
declare VarHolder
var1 : String
var2 : Long
var3 : String
end
also i specified a custom function in the same file, which i have to use
in my rules (it's a example function) :
function String hello(String name) {
return "Hello "+name+"!";
}
.
The declared Type will be used in the java code :
// handle the type as necessary:
// create instances:
Object vars = varHolderTyp.newInstance();
// set attributes values
varHolderTyp.setFromMap(vars,varMap);
// insert fact into a session
StatefulKnowledgeSession ksession = ...
ksession.insert( vars );
When it comes to the "setFromMap", then I get a ClassCastException for
the VarHolderTyp. But when I remove the declaration of the function in
the rule file, then everything works fine (all variables will be filled
correctly). It seems, that the reflection mechanism will not work
correctly, when drools want to create the Pojo for VarHolder and the
Static Method for the function. But it s very difficult to debug,
because the exception fires in the drools engine.
Maybe I've make a mistake so anyone knows a solution for this problem
or can tell me, where my mistake is. It will be nice, when I can declare
a type and a function together in one rule file. At the moment, I
created a java class for VarHolder, so the exception does not appear,
but I m losing a lot of dynamic.
Please give me a hint