對於淹沒彈簧批SO隊列感到抱歉。Spring批處理上下文持有者null
我從作業範圍模式移動,因爲那appears to not work in XML configuration for 3.0.6。儘管我可能會感到困惑。
我試圖繼續步驟範圍,因爲這似乎工作。這是我的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"/>
但我得到的錯誤從我的最高級別的工作,其子女的工作,其子步驟級聯下來,這些步驟豆類,最後是由...造成的......
引起:org.springframework.beans.factory.BeanCreationException:創建名爲'someService'的bean時出錯:範圍'step'對當前線程無效;考慮爲這個bean定義一個範圍代理,如果你打算從一個單例中引用它;嵌套異常是java.lang.IllegalStateException:沒有上下文持有者可用於步驟範圍 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:341) at org.springframework.beans.factory.support .AbstractBeanFactory.getBean(AbstractBeanFactory.java:191) 在org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) ...... 79多個 致:java.lang.IllegalStateException:沒有上下文持有者可用於步驟範圍 at org.springframework.batch.core.scope.StepScope.getContext(StepScope.java:167) at org.springframework.batch.core.scope.StepScope.get(StepScope.java:99) at org.springframework.be ans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:327) ... 81更多
是否需要在我的工作上初始化一些上下文?或者是春季批量與代理服務器相互碰撞,這個代理服務器很容易被客戶利用?
對不起,我並不是指將工作範圍視爲無效選項,但是,我無法在應用程序啓動時獲得任何有效的工作範圍。提到代理可能在準備好之前被調用是一個非常有趣的觀點,我認爲resteasy工廠正在實現一個AfterProperties設置界面。明天我會深入研究。 – TheNorthWes
在堆棧跟蹤中,如果您不會錯過其他100個幀,則在代理上進行調用相對容易。 'afterPropertiesSet'不應該是一個問題。當範圍bean實際實例化時,它會在調用代理時調用。 – Artefacto
嗯有趣。所有這一切都發生在野蠻人開始我們的應用程序時。我會做一些更深入的日誌挖掘並回復你。我現在遠離我的機器,但我會嘗試應用您的想法,看看我能否取得進展。你是否通過Xml配置在作業範圍的bean上取得了進展?我不能得到任何東西認識到3.0.6 – TheNorthWes