【问题标题】:JobOperator could not be instantiatedJobOperator 无法实例化
【发布时间】:2016-07-07 18:02:36
【问题描述】:

当我尝试运行此代码来执行批处理作业时:

JobOperator jo = BatchRuntime.getJobOperator();
Properties props = new Properties();
long jobId = jo.start("tweetimport", props);

我不断收到错误消息。当我试图从 servlet 运行它时,我得到了这个错误:

Severe:   Could not instantiate service: com.ibm.jbatch.container.impl.BatchKernelImpl due to exception:java.lang.reflect.InvocationTargetException
Warning:   StandardWrapperValve[KwetterServlet]: Servlet.service() for servlet KwetterServlet threw exception
java.util.ServiceConfigurationError: javax.batch.operations.JobOperator: Provider com.ibm.jbatch.container.api.impl.JobOperatorImpl could not be instantiated

当我从一个普通的 java 类运行它时,我得到了这个错误:

mrt 21, 2016 10:19:08 AM javax.batch.runtime.BatchRuntime getJobOperator
WARNING: The ServiceLoader was unable to find an implementation for JobOperator. Check classpath for META-INF/services/javax.batch.operations.JobOperator file.
Exception in thread "main" java.lang.NullPointerException

我在其他来源 > src/main/resources > META-INF.batch-jobs 中有这个 tweetimport.xml 文件

<job id="tweetimport" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">
<properties>
    <property name="input_file" value="/KwetterBackend/kwetter-input.json"/>
</properties>
<step id="process">
    <chunk item-count="100">
        <reader ref="TweetReader"></reader>
        <processor ref="TweetProcessor"></processor>
        <writer ref="TweetWriter"></writer>
    </chunk>
</step>

我无法弄清楚为什么会出现此错误。 The link to my project

【问题讨论】:

  • 路径上有需要的 jar 吗?
  • 我将 java.batch-api 添加到依赖项中

标签: java batch-processing


【解决方案1】:

我已经找到答案了,我只好启动这个程序:glassfish-4.1\bin\asadmin,然后执行这一行:

set-batch-runtime-configuration --datasourcelookupname nameofyourJDBCdatasource

现在可以正常使用了。

【讨论】:

    猜你喜欢
    • 2021-04-19
    • 2022-01-03
    • 2016-06-09
    • 2020-10-26
    • 2016-11-22
    • 2016-02-29
    • 2017-01-29
    • 2020-08-30
    • 2011-02-28
    相关资源
    最近更新 更多