diff --git a/src/com/serotonin/mango/MangoContextListener.java b/src/com/serotonin/mango/MangoContextListener.java index cf017e61f2..93c436daf4 100644 --- a/src/com/serotonin/mango/MangoContextListener.java +++ b/src/com/serotonin/mango/MangoContextListener.java @@ -92,6 +92,11 @@ public class MangoContextListener implements ServletContextListener { public void contextInitialized(ServletContextEvent evt) { try { initialized(evt); + // Notify the event manager of the startup. + SystemEventType.raiseEvent(new SystemEventType( + SystemEventType.TYPE_SYSTEM_STARTUP), System + .currentTimeMillis(), false, new LocalizableMessage( + "event.system.startup")); } catch (Exception ex) { log.error(ex.getMessage(), ex); throw ex; @@ -163,11 +168,7 @@ private void initialized(ServletContextEvent evt) { reportsInitialize(); maintenanceInitialize(); - // Notify the event manager of the startup. - SystemEventType.raiseEvent(new SystemEventType( - SystemEventType.TYPE_SYSTEM_STARTUP), System - .currentTimeMillis(), false, new LocalizableMessage( - "event.system.startup")); + try { diff --git a/src/com/serotonin/mango/rt/maint/WorkItemMonitor.java b/src/com/serotonin/mango/rt/maint/WorkItemMonitor.java index 157fcfea8f..8043a1dca3 100644 --- a/src/com/serotonin/mango/rt/maint/WorkItemMonitor.java +++ b/src/com/serotonin/mango/rt/maint/WorkItemMonitor.java @@ -6,9 +6,13 @@ import com.serotonin.mango.Common; import com.serotonin.timer.FixedRateTrigger; import com.serotonin.timer.TimerTask; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.scada_lts.monitor.type.IntegerMonitor; public class WorkItemMonitor extends TimerTask { + + private static final Log LOG = LogFactory.getLog(WorkItemMonitor.class); private static final long TIMEOUT = 1000 * 10; // Run every ten seconds. /** @@ -40,6 +44,11 @@ private WorkItemMonitor() { @Override public void run(long fireTime) { + if(Common.ctx == null || Common.ctx.getBackgroundProcessing() == null) { + LOG.warn("Scada-LTS context terminated"); + return; + } + BackgroundProcessing bp = Common.ctx.getBackgroundProcessing(); mediumPriorityServiceQueueSize.setValue(bp.getMediumPriorityServiceQueueSize());