My goal is starting JSR-352 batch jobs through a Quartz scheduler on a GlassFish server, but there's a big issue. First of all, here's my code.
My JSR-352 job:
<job id="myJob" ...>
<step id="myBatchlet">
<batchlet ref="mypackage.MyBatchlet" />
</step>
</job>
The corresponding Java code:
public class MyBatchlet implements Batchlet {
@Override
public String process() throws Exception {
System.out.println("Hello World!");
return BatchStatus.COMPLETED.toString();
}
@Override
public void stop() throws Exception {
}
}
When I start this job on a GlassFish 4.0 b89 server via a servlet, it works perfectly:
public class StartJobServlet extends HttpServlet {
private void processRequest(...) throws ... {
long executionId = BatchRuntime.getJobOperator().start("myJob", new Properties());
System.out.println("myJob started, execution ID = " + executionId);
}
}
But now I want to use a Quartz 2.2.3 scheduler, so I've written a Quartz job this way:
public class StartMyJob implements Job {
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
long executionId = BatchRuntime.getJobOperator().start("myJob", new Properties());
System.out.println("myJob started, execution ID = " + executionId);
}
}
and I've configured Quartz and a trigger for this job.
But when myJob is supposed to be started, it remains in STARTING state and never actually runs.
According to the logs, the com.ibm.jbatch.container.util.BatchWorkUnit::run
procedure which actually launches the batch job, is never called whereas it is when using a servlet.
EDIT: I've found someone else's similar issue (same symptoms) there, but the given solution can't fit since I have no glassfish-web.xml file.