org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [test.AbstractNode] for property 'parent'

Spring JIRA | kamaljeet sandhu | 1 decade ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    If I set a property on a bean which is a bean itself then reference the outer/parent this works when aspects are not applied but not when they are. The following fragment works when no aspects are applied. <bean id="parentNode" class="test.TestNode"> <property name="name" value="parent"/> <property name="child"> <bean id="childNode" class="test.TestNode"> <property name="name" value="child"/> <property name="parent" value="parentNode"/> </bean> </property> </bean> However when I add the following aspect I get an error. <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"> <property name="proxyTargetClass" value="true"/> </bean> <bean class="org.springframework.aop.support.DefaultPointcutAdvisor"> <property name="pointcut"> <bean class="test.NodePointcut"/> </property> <property name="advice"> <bean class="test.TestAdvice"/> </property> </bean> [java] 2005-09-13 17:13:00,026 [main] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [spring.xml] [java] 2005-09-13 17:13:00,120 [main] INFO org.springframework.beans.factory.xml.XmlBeanFactory - Creating shared instance of singleton bean 'parentNode' [java] Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'childNode' defined in class path resource [spring.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [test.AbstractNode] for property 'parent'] [java] PropertyAccessExceptionsException (1 errors) [java] org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [test.AbstractNode] for property 'parent' [java] at org.springframework.beans.BeanWrapperImpl.doTypeConversionIfNecessary(BeanWrapperImpl.java:1103) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:848) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:733) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:890) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:917) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:906) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1026) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:823) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345) [java] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:147) [java] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:96) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1012) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:823) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345) [java] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226) [java] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147) [java] at test.TestNode.main(TestNode.java:51)

    Spring JIRA | 1 decade ago | kamaljeet sandhu
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [test.AbstractNode] for property 'parent'
  2. 0

    If I set a property on a bean which is a bean itself then reference the outer/parent this works when aspects are not applied but not when they are. The following fragment works when no aspects are applied. <bean id="parentNode" class="test.TestNode"> <property name="name" value="parent"/> <property name="child"> <bean id="childNode" class="test.TestNode"> <property name="name" value="child"/> <property name="parent" value="parentNode"/> </bean> </property> </bean> However when I add the following aspect I get an error. <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"> <property name="proxyTargetClass" value="true"/> </bean> <bean class="org.springframework.aop.support.DefaultPointcutAdvisor"> <property name="pointcut"> <bean class="test.NodePointcut"/> </property> <property name="advice"> <bean class="test.TestAdvice"/> </property> </bean> [java] 2005-09-13 17:13:00,026 [main] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [spring.xml] [java] 2005-09-13 17:13:00,120 [main] INFO org.springframework.beans.factory.xml.XmlBeanFactory - Creating shared instance of singleton bean 'parentNode' [java] Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'childNode' defined in class path resource [spring.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [test.AbstractNode] for property 'parent'] [java] PropertyAccessExceptionsException (1 errors) [java] org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [test.AbstractNode] for property 'parent' [java] at org.springframework.beans.BeanWrapperImpl.doTypeConversionIfNecessary(BeanWrapperImpl.java:1103) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:848) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:733) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:890) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:917) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:906) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1026) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:823) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345) [java] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:147) [java] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:96) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1012) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:823) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345) [java] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226) [java] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147) [java] at test.TestNode.main(TestNode.java:51)

    Spring JIRA | 1 decade ago | Martin Thompson
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [test.AbstractNode] for property 'parent'
  3. 0

    If I set a property on a bean which is a bean itself then reference the outer/parent this works when aspects are not applied but not when they are. The following fragment works when no aspects are applied. <bean id="parentNode" class="test.TestNode"> <property name="name" value="parent"/> <property name="child"> <bean id="childNode" class="test.TestNode"> <property name="name" value="child"/> <property name="parent" value="parentNode"/> </bean> </property> </bean> However when I add the following aspect I get an error. <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"> <property name="proxyTargetClass" value="true"/> </bean> <bean class="org.springframework.aop.support.DefaultPointcutAdvisor"> <property name="pointcut"> <bean class="test.NodePointcut"/> </property> <property name="advice"> <bean class="test.TestAdvice"/> </property> </bean> [java] 2005-09-13 17:13:00,026 [main] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [spring.xml] [java] 2005-09-13 17:13:00,120 [main] INFO org.springframework.beans.factory.xml.XmlBeanFactory - Creating shared instance of singleton bean 'parentNode' [java] Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'childNode' defined in class path resource [spring.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [test.AbstractNode] for property 'parent'] [java] PropertyAccessExceptionsException (1 errors) [java] org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [test.AbstractNode] for property 'parent' [java] at org.springframework.beans.BeanWrapperImpl.doTypeConversionIfNecessary(BeanWrapperImpl.java:1103) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:848) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:733) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:890) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:917) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:906) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1026) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:823) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345) [java] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:147) [java] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:96) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1012) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:823) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345) [java] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226) [java] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147) [java] at test.TestNode.main(TestNode.java:51)

    Spring JIRA | 1 decade ago | kamaljeet sandhu
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [test.AbstractNode] for property 'parent'
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    If I set a property on a bean which is a bean itself then reference the outer/parent this works when aspects are not applied but not when they are. The following fragment works when no aspects are applied. <bean id="parentNode" class="test.TestNode"> <property name="name" value="parent"/> <property name="child"> <bean id="childNode" class="test.TestNode"> <property name="name" value="child"/> <property name="parent" value="parentNode"/> </bean> </property> </bean> However when I add the following aspect I get an error. <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"> <property name="proxyTargetClass" value="true"/> </bean> <bean class="org.springframework.aop.support.DefaultPointcutAdvisor"> <property name="pointcut"> <bean class="test.NodePointcut"/> </property> <property name="advice"> <bean class="test.TestAdvice"/> </property> </bean> [java] 2005-09-13 17:13:00,026 [main] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [spring.xml] [java] 2005-09-13 17:13:00,120 [main] INFO org.springframework.beans.factory.xml.XmlBeanFactory - Creating shared instance of singleton bean 'parentNode' [java] Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'childNode' defined in class path resource [spring.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [test.AbstractNode] for property 'parent'] [java] PropertyAccessExceptionsException (1 errors) [java] org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [test.AbstractNode] for property 'parent' [java] at org.springframework.beans.BeanWrapperImpl.doTypeConversionIfNecessary(BeanWrapperImpl.java:1103) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:848) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:733) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:890) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:917) [java] at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:906) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1026) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:823) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345) [java] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:147) [java] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:96) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1012) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:823) [java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345) [java] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226) [java] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147) [java] at test.TestNode.main(TestNode.java:51)

    Spring JIRA | 1 decade ago | Martin Thompson
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [test.AbstractNode] for property 'parent'
  6. 0

    Problems with Spring setup in tomcat (Spring forum at Coderanch)

    coderanch.com | 8 months ago
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.apache.naming.NamingContext] to required type [org.springframework.core.io.Resource] for property 'location'

    Root Cause Analysis

    1. org.springframework.beans.TypeMismatchException

      Failed to convert property value of type [java.lang.String] to required type [test.AbstractNode] for property 'parent'

      at org.springframework.beans.BeanWrapperImpl.doTypeConversionIfNecessary()
    2. Spring Beans
      AbstractBeanFactory.getBean
      1. org.springframework.beans.BeanWrapperImpl.doTypeConversionIfNecessary(BeanWrapperImpl.java:1103)
      2. org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:848)
      3. org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:733)
      4. org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:890)
      5. org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:917)
      6. org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:906)
      7. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1026)
      8. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:823)
      9. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345)
      10. org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:147)
      11. org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:96)
      12. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1012)
      13. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:823)
      14. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345)
      15. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
      16. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
      16 frames
    3. test
      TestNode.main
      1. test.TestNode.main(TestNode.java:51)
      1 frame