I have used the solution described in this discussion to implement BackgroundJobManager as an inner class inside my JSF bean class. I have also created an ABCTask (also an inner class) as a thread that will run at the scheduled time for the BackgroundJobManager. I have a requirement to push a message onto the JSF page but doing so from the task class ABCTask results in an NPE. The same thing works for the outer bean so i'm convinced it's something to do with the context of this inner class and the bean. Would appreciate if anyone knows a solution for this.
My inner class code is as below :
public class ABCTask implements Runnable {
public ABCTask() {
}
@Override
public void run() {
setTimeoutOccuredFlag(true);
try {
if (getActiveControlledAgent().isEventLogRunning()) {
getActiveControlledAgent().setEventLogRunning(false);
}
printTimeoutMessage();
logger_o.fine("Now leaving the ABCTask ...");
} catch (Exception e) {
logger_o.error("An error while idling "+e.getMessage());
}
}
}
The $printTimeoutMessage() is as follows :
void printTimeoutMessage() {
FacesUtils.addErrorMessage(MESSAGES.getString("common.timeoutOccured"));
}