0

I try to get the running executions while performing Java-EE batch executions. While first execution via BatchRuntime.getJobOperator().start(JOBNAME,parameters) everything works fine:

BatchRuntime.getJobOperator().getRunningExecutions(JOBNAME) provides the correct execution and BatchRuntime.getJobOperator().getJobInstanceCount(JOBNAME) results in "1".

The batch-execution finishes (with BatchStatus.COMPLETED.toString()). During all successive runs following situation occurs:

BatchRuntime.getJobOperator().getJobInstanceCount(JOBNAME)-result increases, so it becomes 2, 3, ....

BatchRuntime.getJobOperator().getRunningExecutions(JOBNAME) throws:

javax.batch.operations.NoSuchJobException: Job Name TestBatchProcessing not found
at org.apache.batchee.container.impl.JobOperatorImpl.getRunningExecutions(JobOperatorImpl.java:314)
at ....BusinessLogic.process(BusinessLogic.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.batchee.container.proxy.BatchProxyInvocationHandler.invoke(BatchProxyInvocationHandler.java:55)
at com.sun.proxy.$Proxy125.process(Unknown Source)
at org.apache.batchee.container.impl.controller.batchlet.BatchletStepController.invokeBatchlet(BatchletStepController.java:58)
at org.apache.batchee.container.impl.controller.batchlet.BatchletStepController.invokeCoreStep(BatchletStepController.java:86)
at org.apache.batchee.container.impl.controller.BaseStepController.execute(BaseStepController.java:152)
at org.apache.batchee.container.impl.controller.ExecutionTransitioner.doExecutionLoop(ExecutionTransitioner.java:106)
at org.apache.batchee.container.impl.controller.FlowController.execute(FlowController.java:58)
at org.apache.batchee.container.impl.controller.ExecutionTransitioner.doExecutionLoop(ExecutionTransitioner.java:106)
at org.apache.batchee.container.impl.controller.JobThreadRootController.originateExecutionOnThread(JobThreadRootController.java:110)
at org.apache.batchee.container.util.BatchWorkUnit.run(BatchWorkUnit.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.batchee.container.util.ClassLoaderAwareHandler.invoke(ClassLoaderAwareHandler.java:39)
at com.sun.proxy.$Proxy123.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Here are the attribute values of the running Jobexecution which should be found by getRunningExecutions (but didn't):

jobProperties: {createTime=2016-08-18 12:45:05.559}
batchStatus: STARTED
exitStatus: null
jobName: TestBatchProcessing
instanceId: 1
executionId: 1

Does anyone know the reason for this exception? Is it necessary, to clean up job instances? If required, I can append concrete code snippets.

Thank you in advance for your answer.

Edit: getJobInstanceCount does not keep being 2. It increases by one everytime a new job starts.

tpunt
  • 2,552
  • 1
  • 12
  • 18
Alex R.
  • 205
  • 1
  • 10
  • In the first part of your question, you said that the batch-execution finishes with status _COMPLETED_. Then you wished to have all the execution ids of this job with are still running, am I right ? However, when an execution is _COMPLETED_, it is not running anymore. A running execution has status _STARTED_, so you won't find it using `JobOperator#getRunningExecutions(String)`. You should use `JobOperator#getJobExecution(long)`. – Mincong Huang Aug 19 '16 at 08:39
  • No, I query for the running executions always during execution: "While first execution ... everything works fine:...". After that: "The batch-execution finishes". Then "_During_ all successive runs following situation occurs..." – Alex R. Aug 19 '16 at 10:32
  • This looks like a bug. I opened an issue: [BATCHEE-112](https://issues.apache.org/jira/browse/BATCHEE-112) – Scott Kurz Sep 06 '16 at 21:22

0 Answers0