2

我在我的项目中使用批处理作业并将其部署在 weblogic 上。我在 weblogic 控制台中设置数据源和模式名称。当我想通过运行开始工作时,BatchRuntime.getJobOperator().start("test-job", new Properties())出现以下错误:

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)

在 EXECUTIONINSTANCEDATA 我有以下记录:

+-------------+-----------------+--------------------------------+-------------+-----------+--------------------------------+--------------+---------------+--------------+
| "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"    | ""           |
+-------------+-----------------+--------------------------------+-------------+-----------+--------------------------------+--------------+---------------+--------------+

编辑:新堆栈跟踪(由 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
4

1 回答 1

0

我在 WLS 12.2.1.2.0 中遇到了类似的问题。仅当使用 EAR 部署重新启动 WLS 但在第一次部署所述 EAR 部署后才能正常工作时,才会出现该错误。

问题是一个带有注释的单例bean @Startup,它将调用并将其存储JobOperator在私有字段中,如下所示:

private JobOperator jobOperator;

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

解决方案是删除@Startup注释,以便 WLS 可以初始化批处理运行时,而不是使用 EAR 文件的类加载器,@PostConstruct然后BatchRuntime.getJobOperator()每次在应用程序中需要 JobOperator 时调用

于 2019-08-06T11:15:50.307 回答