I use batch job in my project and i deployed it on weblogic. I set datasource and schema name in weblogic console. When I want to start job by running BatchRuntime.getJobOperator().start("test-job", new Properties())
i got below error:
javax.batch.operations.JobStartException: java.lang.NullPointerException
at com.ibm.jbatch.container.api.impl.JobOperatorImpl.start(JobOperatorImpl.java:92)
at com.test.job.JobUtils.startJob(JobUtils.java:19)
at com.test.job.WaitScheduler.execute(WaitScheduler.java:33)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused By: java.lang.NullPointerException
at com.ibm.jbatch.container.services.impl.SPIDelegatingThreadPoolServiceImpl.executeTask(SPIDelegatingThreadPoolServiceImpl.java:59)
at com.ibm.jbatch.container.impl.BatchKernelImpl.startJob(BatchKernelImpl.java:135)
at com.ibm.jbatch.container.api.impl.JobOperatorImpl.startInternal(JobOperatorImpl.java:123)
at com.ibm.jbatch.container.api.impl.JobOperatorImpl.start(JobOperatorImpl.java:88)
at com.test.job.JobUtils.startJob(JobUtils.java:19)
at com.test.job.WaitScheduler.execute(WaitScheduler.java:33)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
In EXECUTIONINSTANCEDATA I have below record:
+-------------+-----------------+--------------------------------+-------------+-----------+--------------------------------+--------------+---------------+--------------+
| "JOBEXECID" | "JOBINSTANCEID" | "CREATETIME" | "STARTTIME" | "ENDTIME" | "UPDATETIME" | "PARAMETERS" | "BATCHSTATUS" | "EXITSTATUS" |
+-------------+-----------------+--------------------------------+-------------+-----------+--------------------------------+--------------+---------------+--------------+
| "25457" | "25457" | "20-APR-18 12.55.24.157000 PM" | "" | "" | "20-APR-18 12.55.24.157000 PM" | "<BLOB>" | "STARTING" | "" |
+-------------+-----------------+--------------------------------+-------------+-----------+--------------------------------+--------------+---------------+--------------+
EDIT: New stack trace (job scheduled by managedScheduledExecutorService)
javax.batch.operations.JobStartException: java.lang.NullPointerException
at com.ibm.jbatch.container.api.impl.JobOperatorImpl.start(JobOperatorImpl.java:92)
at com.test.job.JobUtils.startJob(JobUtils.java:22)
at com.test.job.JobStarter.run(JobStarter.java:18)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at weblogic.work.concurrent.TaskWrapper.call(TaskWrapper.java:151)
at weblogic.work.concurrent.future.AbstractFutureImpl.runTask(AbstractFutureImpl.java:391)
at weblogic.work.concurrent.future.AbstractFutureImpl.doRun(AbstractFutureImpl.java:436)
at weblogic.work.concurrent.future.ManagedScheduledFutureImpl.timerExpired(ManagedScheduledFutureImpl.java:86)
at weblogic.work.concurrent.future.ManagedPeriodFutureImpl.timerExpired(ManagedPeriodFutureImpl.java:97)
at weblogic.timers.internal.TimerImpl.run(TimerImpl.java:301)
at weblogic.work.concurrent.future.ManagedScheduledFutureImpl.run(ManagedScheduledFutureImpl.java:96)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:352)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:337)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:57)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:644)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:415)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:355)
Caused by: java.lang.NullPointerException: null
at com.ibm.jbatch.container.services.impl.SPIDelegatingThreadPoolServiceImpl.executeTask(SPIDelegatingThreadPoolServiceImpl.java:59)
at com.ibm.jbatch.container.impl.BatchKernelImpl.startJob(BatchKernelImpl.java:135)
at com.ibm.jbatch.container.api.impl.JobOperatorImpl.startInternal(JobOperatorImpl.java:123)
at com.ibm.jbatch.container.api.impl.JobOperatorImpl.start(JobOperatorImpl.java:88)
... 17 common frames omitted
I had similar problem in a WLS 12.2.1.2.0. The error would only occur if the WLS was restarted with an EAR deployment but would work correctly after the first deployment of said EAR deployment.
The issue was a singleton bean annotated with
@Startup
which would call and store theJobOperator
in a private field as such:The solution was to remove the
@Startup
annotation so the WLS could initialize the Batch runtime instead of using the class loader of the EAR file in@PostConstruct
and then callingBatchRuntime.getJobOperator()
every time the JobOperator was needed inside the application