hi,
Im working on a sample test project.
In that im dynamically creating a class ( fact) and compiling it.
here is my test project
--------------------------------------------------------------------------------------
mainJavaclass
public void runRule()
{
try {
System.out.println("\nRunning rule\n");
// go !
URL[] urls = new URL[]{ new URL("file://"+path) };
URLClassLoader ucl = new URLClassLoader(urls);
Class<?> clazz = ucl.loadClass("test.Message");
Object classObj = clazz.newInstance();
Method method = clazz.getDeclaredMethod("setMessage", new
Class[]{String.class});
//System.out.println("facts loaded\n");
method.invoke(classObj, new Object[]{"Hello"});
log.info("==== Calling Rule Runner ======");
Collection facts = new ArrayList();
facts.add(classObj);
// Load and fire our rules files against the data
new RuleRunner().runStatelessRules(RULES_FILES, null, facts, null, null,
logger);
}
catch (Throwable t) {
t.printStackTrace();
}
}
----------------------------------------------------------------------
Fact
package test;
public class Message{
private String message;
public String getMessage(){
return this.message;
}
public void setMessage(String message) {
this.message = message;
}
}
------------------------------------------------------------------------
sample rule
package test
import test.Message;
rule "Your First Rule"
dialect "mvel"
when
m:Message(message != "Good Bye" )
then
System.out.println("First Rule fired "+m.message );
modify(m){ message = "Good Bye"};
end
-----------------------------------------------------------------
console file
http://www.nabble.com/file/p26072723/console.PNG console.PNG
what happens is when i was running the project inside eclipse IDE it works
fine but when i hosted in tomcat and calling from outside ide the rule is
not getting fired.
I think the dyanamically loaded class is not recognised by the rule engine.
suggest me any ideas
Hemanth
--
View this message in context:
http://www.nabble.com/couuld-not-load-fact-to-rule-engine-tp26072723p2607...
Sent from the drools - user mailing list archive at
Nabble.com.