Hi.
I am developing a workflow agent in Jade, using Jess for reasoning, etc. But I'm facing a problem with the 'Value' class, in fetching values from Jess to my
Java program.
myJessAgent.clp:
(defrule rule
(and (a) (b))
=>
(store RESULT 1)
)
(watch facts)
(watch all)
(reset)
(run)
myBasicBehavior.java:
jess = new Rete();
try {
FileReader fr = new FileReader(jessFile);
Jesp j = new Jesp(fr, jess);
j.parse(false);
} catch (JessException re) { System.out.println(re); }
try {
jess.reset();
jess.executeCommand("(assert (a))");
jess.executeCommand("(assert (b))");
Value v = jess.fetch("RESULT");
jess.run();
int i = v.intValue(jess.getGlobalContext());
System.out.println("The answer is: " + i);
jess.run();
} catch (JessException re) {
re.printStackTrace(System.err);
}
After compiling, error on executing is as follows:
==> Focus MAIN
==> f-0 (MAIN::initial-fact)
<== Focus MAIN
==> Focus MAIN
==> f-0 (MAIN::initial-fact)
==> f-1 (MAIN::a)
==> f-2 (MAIN::b)
==> Activation: MAIN::rule1 : f-1, f-2
FIRE 1 MAIN::rule1 f-1, f-2
<== Focus MAIN
*** Uncaught Exception for agent a1 ***
java.lang.NullPointerException
at examples.myjess.myBasicJessBehaviour.action(myBasicJessBehaviour.java:67)
at jade.core.behaviours.Behaviour.actionWrapper(Unknown Source)
at jade.core.Agent.mainLoop(Unknown Source)
at jade.core.Agent.run(Unknown Source)
at java.lang.Thread.run(Thread.java:536)
ERROR: Agent a1 died without being properly terminated !!!
State was 2
I know its probably a silly mistake, but I'm just beginning to use Jess, so can't quite figure it out.
Thanks and regards,
Indira.