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

  • getting bean creation error


    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:

    <beans:bean id="serviceAdapter" class="com.batch.adaptor.ServiceAdaptor" scope="step">
    			<beans:property name="instrumentsList" value="#{stepExecutionContext[instrumentsList]}"/>					
    		<beans:bean id="itemReaderAdaptor" class="org.springframework.batch.item.adapter.ItemReaderAdapter">
    			<beans:property name="targetObject" ref="serviceAdapter"/>
    			<beans:property name="targetMethod" value="nextResponse"/>			
    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 AutowireCapableBeanFactory.initializeBean(Abstract
    at AutowireCapableBeanFactory.doCreateBean(AbstractAu
    at AutowireCapableBeanFactory.createBean(AbstractAuto
    at BeanFactory$1.getObject( 91)
    at ingletonBeanRegistry.getSingleton(DefaultSingleton
    at BeanFactory.doGetBean( )
    at BeanFactory.getBean(
    at istableBeanFactory.preInstantiateSingletons(Defaul
    at ationContext.finishBeanFactoryInitialization(Abstr
    at ationContext.refresh(AbstractApplicationContext.ja va:425)
    at plicationContext.<init>(ClassPathXmlApplicationCon
    at plicationContext.<init>(ClassPathXmlApplicationCon
    at com.jpmchase.equity.request.EquityRequestIntercept or.main(
    Caused by: java.lang.IllegalStateException: target class must declare a method with matching name and parameter types
    at org.springframework.util.Assert.state( 384)
    at org.springframework.batch.item.adapter.AbstractMet hodInvokingDelegator.afterPropertiesSet(AbstractMe
    at AutowireCapableBeanFactory.invokeInitMethods(Abstr
    at AutowireCapableBeanFactory.initializeBean(Abstract
    ... 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.