org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enumBugTest' defined in class path resource [EnumTestApplicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'uk.org.sith.jeraz.Test[]' for property 'enumTypes'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [uk.org.sith.jeraz.Test] for property 'enumTypes[0]': no matching editors or conversion strategy found

Spring JIRA | Antony Lees | 7 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Given an array of enums, if the array is injected using a comma-separated list of string values, the injection will fail if there are more than one value eg <property name="enumTypes" value="TEST1,TEST2"/> However, it will work if there is only 1 value eg <property name="enumTypes" value="TEST1"/> To test this I tried a list of enums, an array of enums and an array of strings. The strings and the list work, but the enum array does not and fails with this exception: Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enumBugTest' defined in class path resource [EnumTestApplicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'uk.org.sith.jeraz.Test[]' for property 'enumTypes'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [uk.org.sith.jeraz.Test] for property 'enumTypes[0]': no matching editors or conversion strategy found at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:289) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:286) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:188) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:558) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:852) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:422) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93) at uk.org.sith.jeraz.EnumTestMain.main(EnumTestMain.java:10) Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'uk.org.sith.jeraz.Test[]' for property 'enumTypes'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [uk.org.sith.jeraz.Test] for property 'enumTypes[0]': no matching editors or conversion strategy found at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:452) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1351) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1310) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511) ... 11 more Caused by: java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [uk.org.sith.jeraz.Test] for property 'enumTypes[0]': no matching editors or conversion strategy found at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:259) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:121) at org.springframework.beans.TypeConverterDelegate.convertToTypedArray(TypeConverterDelegate.java:478) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:197) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:135) at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:442) ... 15 more My test code is below: package uk.org.sith.jeraz; import org.springframework.context.support.ClassPathXmlApplicationContext; public class EnumTestMain { public static void main(String[] args) { EnumTestMain main = new EnumTestMain(); new ClassPathXmlApplicationContext(main.getPaths()); } public String[] getPaths() { return new String[] {"EnumTestApplicationContext.xml"}; } } package uk.org.sith.jeraz; import java.util.List; public class EnumBugTest { private Test[] enumTypes; private String[] stringTypes; private List<Test> enumList; public void setEnumTypes(Test[] enumTypes) { this.enumTypes = enumTypes; } public void setStringTypes(String[] stringTypes) { this.stringTypes = stringTypes; } public void setEnumList(List<Test> enumList) { this.enumList = enumList; } } <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean name="enumBugTest" class="uk.org.sith.jeraz.EnumBugTest"> <property name="stringTypes" value="HELLO,STRING"/> <property name="enumTypes" value="TEST1,TEST2"/> <property name="enumList"> <list> <value>TEST1</value> <value>TEST2</value> </list> </property> </bean> </beans>

    Spring JIRA | 7 years ago | Antony Lees
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enumBugTest' defined in class path resource [EnumTestApplicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'uk.org.sith.jeraz.Test[]' for property 'enumTypes'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [uk.org.sith.jeraz.Test] for property 'enumTypes[0]': no matching editors or conversion strategy found
  2. 0

    Given an array of enums, if the array is injected using a comma-separated list of string values, the injection will fail if there are more than one value eg <property name="enumTypes" value="TEST1,TEST2"/> However, it will work if there is only 1 value eg <property name="enumTypes" value="TEST1"/> To test this I tried a list of enums, an array of enums and an array of strings. The strings and the list work, but the enum array does not and fails with this exception: Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enumBugTest' defined in class path resource [EnumTestApplicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'uk.org.sith.jeraz.Test[]' for property 'enumTypes'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [uk.org.sith.jeraz.Test] for property 'enumTypes[0]': no matching editors or conversion strategy found at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:289) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:286) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:188) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:558) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:852) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:422) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93) at uk.org.sith.jeraz.EnumTestMain.main(EnumTestMain.java:10) Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'uk.org.sith.jeraz.Test[]' for property 'enumTypes'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [uk.org.sith.jeraz.Test] for property 'enumTypes[0]': no matching editors or conversion strategy found at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:452) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1351) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1310) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511) ... 11 more Caused by: java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [uk.org.sith.jeraz.Test] for property 'enumTypes[0]': no matching editors or conversion strategy found at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:259) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:121) at org.springframework.beans.TypeConverterDelegate.convertToTypedArray(TypeConverterDelegate.java:478) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:197) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:135) at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:442) ... 15 more My test code is below: package uk.org.sith.jeraz; import org.springframework.context.support.ClassPathXmlApplicationContext; public class EnumTestMain { public static void main(String[] args) { EnumTestMain main = new EnumTestMain(); new ClassPathXmlApplicationContext(main.getPaths()); } public String[] getPaths() { return new String[] {"EnumTestApplicationContext.xml"}; } } package uk.org.sith.jeraz; import java.util.List; public class EnumBugTest { private Test[] enumTypes; private String[] stringTypes; private List<Test> enumList; public void setEnumTypes(Test[] enumTypes) { this.enumTypes = enumTypes; } public void setStringTypes(String[] stringTypes) { this.stringTypes = stringTypes; } public void setEnumList(List<Test> enumList) { this.enumList = enumList; } } <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean name="enumBugTest" class="uk.org.sith.jeraz.EnumBugTest"> <property name="stringTypes" value="HELLO,STRING"/> <property name="enumTypes" value="TEST1,TEST2"/> <property name="enumList"> <list> <value>TEST1</value> <value>TEST2</value> </list> </property> </bean> </beans>

    Spring JIRA | 7 years ago | Antony Lees
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enumBugTest' defined in class path resource [EnumTestApplicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'uk.org.sith.jeraz.Test[]' for property 'enumTypes'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [uk.org.sith.jeraz.Test] for property 'enumTypes[0]': no matching editors or conversion strategy found
  3. 0

    " org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.jdbc.datasource

    Stack Overflow | 2 years ago | Ashvin Ranpariya
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 't' defined in class path resource [resources/spring.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'URL' of bean class [beans.Test]: Bean property 'URL' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Getting error while dynamically providing input,output path

    Stack Overflow | 11 months ago | Varun Maurya
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'step1': Cannot resolve reference to bean 'itemReader' while setting bean property 'itemReader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'itemReader' defined in class path resource [spring/config/process-config.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type [com.sun.proxy.$Proxy11 implementing org.springframework.batch.item.ItemStreamReader,org.springframework.batch.item.ItemStream,org.springframework.aop.scope.ScopedObject,java.io.Serializable,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.batch.item.file.MultiResourceItemReader] for property 'multiReader'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.sun.proxy.$Proxy11 implementing org.springframework.batch.item.ItemStreamReader,org.springframework.batch.item.ItemStream,org.springframework.aop.scope.ScopedObject,java.io.Serializable,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.batch.item.file.MultiResourceItemReader] for property 'multiReader': no matching editors or conversion strategy found
  6. 0

    Issues in serializers config

    GitHub | 4 years ago | dsukhoroslov
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hzInstance': Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public static com.hazelcast.core.HazelcastInstance com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.config.Config)] threw exception; nested exception is com.hazelcast.nio.serialization.HazelcastSerializationException: java.lang.NoSuchMethodException: com.hazelcast.nio.serialization.PortableSerializer.<init>()

  1. batwalrus76 3 times, last 3 months ago
  2. Andreas Häber 2 times, last 1 month ago
  3. treefolk 1 times, last 2 months ago
  4. mauritius 2 times, last 3 months ago
  5. jpvee 1 times, last 3 months ago
25 more registered users
70 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.IllegalStateException

    Cannot convert value of type [java.lang.String] to required type [uk.org.sith.jeraz.Test] for property 'enumTypes[0]': no matching editors or conversion strategy found

    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary()
  2. Spring Beans
    DefaultListableBeanFactory.preInstantiateSingletons
    1. org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:259)
    2. org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:121)
    3. org.springframework.beans.TypeConverterDelegate.convertToTypedArray(TypeConverterDelegate.java:478)
    4. org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:197)
    5. org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:135)
    6. org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:442)
    7. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1351)
    8. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1310)
    9. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067)
    10. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
    11. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
    12. org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:289)
    13. org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    14. org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:286)
    15. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:188)
    16. org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:558)
    16 frames
  3. Spring Context
    ClassPathXmlApplicationContext.<init>
    1. org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:852)
    2. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:422)
    3. org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    4. org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
    4 frames
  4. uk.org.sith
    EnumTestMain.main
    1. uk.org.sith.jeraz.EnumTestMain.main(EnumTestMain.java:10)
    1 frame