3

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
moh m
  • 51
  • 6
  • I remove the quartz and again get NPE. I added new stack trace above. – moh m Apr 20 '18 at 22:02
  • Are you packaging the **com.ibm.jbatch.** batch container within your application, or are you getting it from the WebLogic server? – Scott Kurz Apr 20 '18 at 22:16
  • I got it from weblogic and there is no dependency in my package. – moh m Apr 20 '18 at 22:20
  • Roughly speaking: the batch runtime isn't initalizing correctly in WebLogic, but I'm not sure what the problem is. What version of Web Logic? (Also, I deleted my earlier comment about using Quartz, since that wasn't the issue you were hitting.) – Scott Kurz Apr 21 '18 at 01:15
  • Weblogic version: 12.2.1.3.0 – moh m Apr 21 '18 at 03:19
  • It seems like the executor (thread pool) isn't configured correctly. Not too familiar with WebLogic, does [this link](https://docs.oracle.com/middleware/1221/wls/CNFGD/batch-apps.htm#CNFGD374) help any? – Scott Kurz May 04 '18 at 19:18

1 Answers1

0

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 the JobOperator in a private field as such:

private JobOperator jobOperator;

@PostConstruct
public void initialize() {
    jobOperator = BatchRuntime.getJobOperator();
}

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 calling BatchRuntime.getJobOperator() every time the JobOperator was needed inside the application