Announcement Announcement Module
Collapse
No announcement yet.
getting bean creation error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • getting bean creation error

    Hi

    I have a service to get the data from a provider. I can this service a list of IDs and get the data back.
    So first of all I read the list of IDs and chunk it using partitioner.
    Each individual execution context now has the list of instruments.

    I trying to pass this list of instruments from the execution context to the adapter as below:


    Code:
    <beans:bean id="serviceAdapter" class="com.batch.adaptor.ServiceAdaptor" scope="step">
    			<beans:property name="instrumentsList" value="#{stepExecutionContext[instrumentsList]}"/>					
    		</beans:bean>
    		<beans:bean id="itemReaderAdaptor" class="org.springframework.batch.item.adapter.ItemReaderAdapter">
    			<beans:property name="targetObject" ref="serviceAdapter"/>
    			<beans:property name="targetMethod" value="nextResponse"/>			
    		</beans:bean>
    My adaptor class has the getter and setter for the list. But still I am getting below errors:

    Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'itemReaderAdaptor' defined in class path resource [application-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: target class must declare a method with matching name and parameter types
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 91)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:288 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:425)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:139)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:93)
    at com.jpmchase.equity.request.EquityRequestIntercept or.main(EquityRequestInterceptor.java:47)
    Caused by: java.lang.IllegalStateException: target class must declare a method with matching name and parameter types
    at org.springframework.util.Assert.state(Assert.java: 384)
    at org.springframework.batch.item.adapter.AbstractMet hodInvokingDelegator.afterPropertiesSet(AbstractMe thodInvokingDelegator.java:135)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1477)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1417)
    ... 12 more

    I am not sure what can cause this problem. Any help would be appreciated.

  • #2
    You are trying to inject a step scoped bean into a singleton... You probably want to make the ItemReadAdapter step scoped to... Also make sure that the method name matches and that you map any parameters correctly.

    Comment

    Working...
    X