【发布时间】:2016-06-04 15:40:07
【问题描述】:
很抱歉淹没了 Spring Batch SO 队列。
我从 Job Scope 模式继续前进,因为 appears to not work in XML configuration for 3.0.6。不过,我很可能只是感到困惑。
我尝试继续使用 step 范围,因为这似乎可行。这是我的 bean 的 app-context.xml 配置标头。这将启用scope="step" 选项。
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache.xsd">
但是,这些 bean 的创建失败。重要的是,这些是 REST Easy 客户端代理 bean。我是这样定义的:
<bean id="rootServiceBean" scope="step"
class="com.myorg.ServiceProxyFactoryBean"
p:baseUri="${rest.base.uri}"
p:ticket="#{jobExecutionContext['jobSecrets']}" abstract="true"/>
然后在我的实例上:
<bean id="someServiceObject"
parent="rootServiceBean"
p:serviceInterface="com.myOrg.someServiceRest"/>
但是我从我的顶级作业、它的子作业、它的子步骤以及那些步骤 bean 中级联错误,这些错误最终是由...引起的。
原因:org.springframework.beans.factory.BeanCreationException:创建名称为'someService'的bean时出错:范围'step'对当前线程无效;如果您打算从单例中引用它,请考虑为该 bean 定义一个作用域代理;嵌套异常是 java.lang.IllegalStateException: No context holder available for step scope 在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:341) 在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191) 在 org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) ... 79 更多 原因:java.lang.IllegalStateException:没有可用于步骤范围的上下文持有者 在 org.springframework.batch.core.scope.StepScope.getContext(StepScope.java:167) 在 org.springframework.batch.core.scope.StepScope.get(StepScope.java:99) 在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:327) ... 81 更多
我的工作需要初始化一些上下文吗?还是 spring-batch 与 rest easy 客户端正在利用的代理发生冲突?
【问题讨论】:
标签: java spring spring-batch