In my application I want to create some beans in scope step. I have a problem with entityManagerFactory it gives me this error: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.scopedTarget.entityManagerFactory': Scope 'step' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No context holder available for step scope
here is the way i am creating the beans.
<context:property-placeholder />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource" scope="step">
<aop:scoped-proxy/>
<property name="driverClassName" value="#{jobExecutionContext.get('batchProperties').getProperty('database.driverClass')}" />
<property name="url" value="#{jobExecutionContext.get('batchProperties').getProperty('database.url')}" />
<property name="username" value="#{jobExecutionContext.get('batchProperties').getProperty('database.user')}" />
<property name="password" value="#{jobExecutionContext.get('batchProperties').getProperty('database.password')}" />
</bean>
<bean id="jpaVendorAdapter"
class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter" scope="step">
<aop:scoped-proxy/>
<property name="databasePlatform"
value="org.eclipse.persistence.platform.database.PostgreSQLPlatform" />
<property name="generateDdl" value="false" />
<property name="showSql" value="true" />
</bean>
aop:scoped-proxy/
<bean id="stepScope" class="org.springframework.batch.core.scope.StepScope">
<property name="autoProxy" value="true" />
</bean>
<batch:job id="jobAccountDemo3456111" job-repository="jobRepository"
restartable="true">
<batch:step id="jobAccountDemo3456111.step1" parent="abstractParentStep">
<batch:tasklet>
<batch:listeners>
<batch:listener ref="loadPropertiesListener" />
</batch:listeners>
<batch:chunk reader="importAccountJobResourceReader" />
</batch:tasklet>
</batch:step>
</batch:job>
<bean id="loadPropertiesListener" class="com.kmse.hicp.bof.batch.preset.gen.jpa.imports.PropertyLoaderJobExecutionListener" scope="step">
<property name="pfb">
<bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location" value="file:#{jobParameters['myfile']}" />
</bean>
</property>
</bean>
is there a way to solve this problem
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…