java - JobOperator 无法实例化

标签 java batch-processing

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

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

最佳答案

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

set-batch-runtime-configuration --datasourcelookupname nameofyourJDBCdatasource

现在它工作正常。

关于java - JobOperator 无法实例化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36127480/

相关文章:

java - 需要 REGEX 帮助 - 分解行

java - 如何将eclipse连接到postgresql?

java - Spring 批处理 : How to access the current step's id/name from within an ItemReader or ItemWriter

c# - 设置进程调度程序的框架

Java EE 7 Batch API - MultiResourceItemReader 对应项

java - 如何将 MD5 哈希值转换为字符串?

java - 将Spring Web项目打包到没有Spring Boot的jar(uber-jar)中(非spring-boot项目)

java - 具有 IBM Websphere 依赖项的 SAXParser 实现

spring - 我的工作永远是空的。无法使用 Spring Batch 注入(inject)批处理作业。为什么?

google-cloud-platform - 如何在 Google Cloud 中运行无服务器批处理作业