When timer's action tries to end the token it linked to, the scheduler is crashed with Hibernate ObjectNotFound exception due to the token ending removes all timers.
I rewrite SchedulerSession to avoid it(not perfect but workable):
public void saveTimer(Timer timer) {
try {
// if (session.get(timer.getClass(), timer.getId()) != null)
session.save(timer);
} catch (ObjectNotFoundException e) {
log.debug("timer can't be saved; ignore it");
} catch (Exception e) {
log.error(e);
// jbpmSession.handleException();
throw new JbpmException("couldn't save timer '" + timer
+ "' to the database", e);
}
}
public Iterator findTimersByDueDate() {
List buffer = new ArrayList();
CollectionUtils.addAll(buffer, super.findTimersByDueDate());
return buffer.iterator();
}