I am trying to schedule a model in keel. It schedules but throws a
null pointer exception when it runs. I think I am missing something
obvious, but cannot figure it out. Here is the code that creates the
schedule.
ModelResponse res = request.createResponse();
Scheduler scheduler =
(Scheduler)request.getService(Scheduler.ROLE, "default");
ScheduledRequest sreq =
(ScheduledRequest)request.getService(ScheduledRequest.ROLE,
"default");
ModelRequest mreq =
(ModelRequest)request.getService(ModelRequest.ROLE, "default");
//Add code to add model attributes/parms in the
ModelRequest
// The following sets up the job to run every
two-minutes
// (starting at the 0 th minue for every hour, and
repeating
// every 1 minute). Any missing field value is
treated as
// "*", which means "match every occurence".
mreq.setModel("apptest");
//Add code to
add model attributes/parms in the ModelRequest
// The
following sets up the job to run every two-minutes
// (starting
at the 0 th minue for every hour, and repeating
// every 2
minutes). Any missing field value is treated as
// "*", which
means "match every occurence".
sreq.setSeconds("0");
sreq.setMinutes("0/1");
sreq.setRequest(mreq);
try {
scheduler.schedule(sreq);
}
catch (NestedException e) {
throw new ModelException("Scheduling exception", e);
}
The app test code is:
public class Test extends StandardLogEnabledModel {
/**
* @see org.keel.services.model.Model#execute(org.keel.services.model.ModelRequest)
*/
public ModelResponse execute(ModelRequest request) throws ModelException {
ModelResponse res = request.createResponse();
res.addOutput("hello", "New Test");
DateFormat defaultDate = DateFormat.getDateInstance();
try {
BufferedWriter out = new BufferedWriter(new
FileWriter("/home/tgidding/test.txt"));
out.write(defaultDate.format(new Date()));
out.close();
}
catch (IOException e) {
}
return res;
}
}
http://keelframework.org/documentation
Keelgroup mailing list
[EMAIL PROTECTED]
http://lists.keelframework.com/listinfo.cgi/keelgroup-keelframework.com