Fixed: JobPoller does not run and hence scheduled/async jobs are never run
(OFBIZ-9155)
Symptom:
* services that are invoked with "dispatcher.runAsync" stay "pending" in the
job-list and never get executed
* scheduled jobs don't get executed
Steps to Reproduce
* Login to /webtools
* Schedule a Job to run in 5 mins, (for example service "clearAllEntityCaches")
* Wait 7mins
Expected:
* the scheduled service "clearAllEntityCaches" is not "pending" anymore but
should have status "finished"
Actual:
* scheduled service "clearAllEntityCaches" is still "pending"
Analysis:
The problem can be reproduced with the OFBiz 16.11 branxh as well as
with the OFBiz 16.11.01 zip file version and the trunk
JobPoller does get started on OFBiz start but does get stuck on line:
org.apache.ofbiz.service.job.JobPoller.java: 213-215
The reason is that the "Start.ServerState" never reaches "RUNNING"
Doing a full-text scan through the whole source code shows, that there is no
code at all that sets the ServerState to "RUNNING"
Comparing it to the 15.11-branch. There used to be a line:
serverState.compareAndSet(ServerState.STARTING, ServerState.RUNNING)
no such line exists in 16.11 anymore.
jleroux: I confirm the behaviour in R16 branch as well as in trunk.
Leonard's "patch" is a good solution and works for the R16 branch which is less
changed than the trunk when compared to R15.
The same applies to the trunk with the relative block of code which contains
if (serverState.get() == ServerState.STOPPING) {
The line Leonard propose to add was obviously missed during the recent
refactoring.
Thanks: Leonard Lin
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1779596 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java b/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java
index ada1ff1..65ecce2 100644
--- a/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java
+++ b/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java
@@ -204,6 +204,7 @@
throw new StartupException(e);
}
}
+ serverState.compareAndSet(ServerState.STARTING, ServerState.RUNNING);
}
private static void executeShutdownAfterLoadIfConfigured(