Announcement Announcement Module
Collapse
No announcement yet.
Error while injecting the object to the bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error while injecting the object to the bean

    Hi,
    I have the bean config as shown below.

    <beans:bean id="tasklet" class="com.batch.tasklet.SampleTasklet">
    <beansroperty name="name1" ref="name1"/>
    </beans:bean>

    <beans:bean id ="name1" class ="org.webharvest.runtime.Scraper" scope="step">
    <beans:constructor-arg ref="......"/>
    </beans:bean>

    Here, Scraper is concrete class(This is the class from third party).It is not implementing any interface.
    While running i am getting the below error.

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'crawlerStep': Cannot resolve reference to bean 'harvestTasklet' while setting bean property 'tasklet'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'harvestTasklet' defined in class path resource [crawler/crawler-beans.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy3 implementing org.springframework.aop.scope.ScopedObject,org.spr ingframework.aop.framework.AopInfrastructureBean,o rg.springframework.aop.SpringProxy,org.springframe work.aop.framework.Advised] to required type [org.webharvest.runtime.Scraper] for property 'scraper'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy3 implementing org.springframework.aop.scope.ScopedObject,org.spr ingframework.aop.framework.AopInfrastructureBean,o rg.springframework.aop.SpringProxy,org.springframe work.aop.framework.Advised] to required type [org.webharvest.runtime.Scraper] for property 'scraper': no matching editors or conversion strategy found
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:275)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:104)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1245)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1010)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:472)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:221)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:423)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:729)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:381)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:139)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:83)
    at org.springframework.batch.core.launch.support.Comm andLineJobRunner.start(CommandLineJobRunner.java:1 90)
    at org.springframework.batch.core.launch.support.Comm andLineJobRunner.main(CommandLineJobRunner.java:25 4)
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'harvestTasklet' defined in class path resource [crawler/crawler-beans.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy3 implementing org.springframework.aop.scope.ScopedObject,org.spr ingframework.aop.framework.AopInfrastructureBean,o rg.springframework.aop.SpringProxy,org.springframe work.aop.framework.Advised] to required type [org.webharvest.runtime.Scraper] for property 'scraper'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy3 implementing org.springframework.aop.scope.ScopedObject,org.spr ingframework.aop.framework.AopInfrastructureBean,o rg.springframework.aop.SpringProxy,org.springframe work.aop.framework.Advised] to required type [org.webharvest.runtime.Scraper] for property 'scraper': no matching editors or conversion strategy found
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:480)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:221)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:269)
    ... 19 more
    Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy3 implementing org.springframework.aop.scope.ScopedObject,org.spr ingframework.aop.framework.AopInfrastructureBean,o rg.springframework.aop.SpringProxy,org.springframe work.aop.framework.Advised] to required type [org.webharvest.runtime.Scraper] for property 'scraper'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy3 implementing org.springframework.aop.scope.ScopedObject,org.spr ingframework.aop.framework.AopInfrastructureBean,o rg.springframework.aop.SpringProxy,org.springframe work.aop.framework.Advised] to required type [org.webharvest.runtime.Scraper] for property 'scraper': no matching editors or conversion strategy found
    at org.springframework.beans.BeanWrapperImpl.convertF orProperty(BeanWrapperImpl.java:391)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.convertForProperty(Abst ractAutowireCapableBeanFactory.java:1288)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1249)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1010)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:472)
    ... 28 more
    Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy3 implementing org.springframework.aop.scope.ScopedObject,org.spr ingframework.aop.framework.AopInfrastructureBean,o rg.springframework.aop.SpringProxy,org.springframe work.aop.framework.Advised] to required type [org.webharvest.runtime.Scraper] for property 'scraper': no matching editors or conversion strategy found
    at org.springframework.beans.TypeConverterDelegate.co nvertIfNecessary(TypeConverterDelegate.java:219)
    at org.springframework.beans.TypeConverterDelegate.co nvertIfNecessary(TypeConverterDelegate.java:138)
    at org.springframework.beans.BeanWrapperImpl.convertF orProperty(BeanWrapperImpl.java:386)
    ... 32 more

    How can we resolve this?
    Is there any other way to set auto proxy?

    Any help....

    Regards,
    Siva

  • #2
    Your StepScope instance needs to specify proxytargetClass=true (http://static.springsource.org/sprin...tml#step-scope).

    Comment

    Working...
    X