Java- How to fix my exception in spring framework? -
import java.awt.list; import java.util.properties; public class collectionexample { private list examplelist; private properties exampleprop; public list getexamplelist() { system.out.println("list element : " + examplelist); return examplelist; } public void setexamplelist(list examplelist) { examplelist = examplelist; } public properties getexampleprop() { system.out.println("list element : " + exampleprop); return exampleprop; } public void setexampleprop(properties exampleprop) { this.exampleprop = exampleprop; } }
and main class :
public class collectionexample { private list examplelist; private properties exampleprop; public list getexamplelist() { system.out.println("list element : " + examplelist); return examplelist; } public void setexamplelist(list examplelist) { examplelist = examplelist; } public properties getexampleprop() { system.out.println("list element : " + exampleprop); return exampleprop; } public void setexampleprop(properties exampleprop) { this.exampleprop = exampleprop; } } .xml file : <bean id = "collectionexample" class = "com.demo.spring.beans.collectionexample" > <property name="examplelist"> <list> <value>credit card</value> <value>cod</value> <value>check</value> <value>cash</value> </list> </property> <property name="exampleprop"> <props> <prop key="one">server name</prop> <prop key="one">user name</prop> <prop key="one">password</prop> <prop key="one">secure token</prop> </props> </property> </bean>
there exception : jun 04, 2015 5:56:22 pm org.springframework.context.support.classpathxmlapplicationcontext preparerefresh info: refreshing org.springframework.context.support.classpathxmlapplicationcontext@2d8e6db6: startup date [thu jun 04 17:56:22 irdt 2015]; root of context hierarchy jun 04, 2015 5:56:22 pm org.springframework.beans.factory.xml.xmlbeandefinitionreader loadbeandefinitions info: loading xml bean definitions class path resource [newfile.xml] jun 04, 2015 5:56:22 pm org.springframework.context.support.classpathxmlapplicationcontext refresh warning: exception encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory.beancreationexception: error creating bean name 'collectionexample' defined in class path resource [newfile.xml]: initialization of bean failed; nested exception org.springframework.beans.conversionnotsupportedexception: failed convert property value of type 'java.util.arraylist' required type 'java.awt.list' property 'examplelist'; nested exception java.lang.illegalstateexception: cannot convert value of type [java.util.arraylist] required type [java.awt.list] property 'examplelist': no matching editors or conversion strategy found @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:547) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:476) @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:303) @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:230) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:299) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:194) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:755) @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:757) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:480) @ org.springframework.context.support.classpathxmlapplicationcontext.(classpathxmlapplicationcontext.java:139) @ org.springframework.context.support.classpathxmlapplicationcontext.(classpathxmlapplicationcontext.java:83) @ com.demo.spring.beans.collectionexampleapp.main(collectionexampleapp.java:9) caused by: org.springframework.beans.conversionnotsupportedexception: failed convert property value of type 'java.util.arraylist' required type 'java.awt.list' property 'examplelist'; nested exception java.lang.illegalstateexception: cannot convert value of type [java.util.arraylist] required type [java.awt.list] property 'examplelist': no matching editors or conversion strategy found @ org.springframework.beans.beanwrapperimpl.convertifnecessary(beanwrapperimpl.java:476) @ org.springframework.beans.beanwrapperimpl.convertforproperty(beanwrapperimpl.java:512) @ org.springframework.beans.beanwrapperimpl.convertforproperty(beanwrapperimpl.java:506) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.convertforproperty(abstractautowirecapablebeanfactory.java:1523) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.applypropertyvalues(abstractautowirecapablebeanfactory.java:1482) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.populatebean(abstractautowirecapablebeanfactory.java:1222) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:537) ... 11 more caused by: java.lang.illegalstateexception: cannot convert value of type [java.util.arraylist] required type [java.awt.list] property 'examplelist': no matching editors or conversion strategy found @ org.springframework.beans.typeconverterdelegate.convertifnecessary(typeconverterdelegate.java:287) @ org.springframework.beans.beanwrapperimpl.convertifnecessary(beanwrapperimpl.java:461) ... 17 more
exception in thread "main" org.springframework.beans.factory.beancreationexception: error creating bean name 'collectionexample' defined in class path resource [newfile.xml]: initialization of bean failed; nested exception org.springframework.beans.conversionnotsupportedexception: failed convert property value of type 'java.util.arraylist' required type 'java.awt.list' property 'examplelist'; nested exception java.lang.illegalstateexception: cannot convert value of type [java.util.arraylist] required type [java.awt.list] property 'examplelist': no matching editors or conversion strategy found @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:547) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:476) @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:303) @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:230) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:299) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:194) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:755) @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:757) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:480) @ org.springframework.context.support.classpathxmlapplicationcontext.(classpathxmlapplicationcontext.java:139) @ org.springframework.context.support.classpathxmlapplicationcontext.(classpathxmlapplicationcontext.java:83) @ com.demo.spring.beans.collectionexampleapp.main(collectionexampleapp.java:9) caused by: org.springframework.beans.conversionnotsupportedexception: failed convert property value of type 'java.util.arraylist' required type 'java.awt.list' property 'examplelist'; nested exception java.lang.illegalstateexception: cannot convert value of type [java.util.arraylist] required type [java.awt.list] property 'examplelist': no matching editors or conversion strategy found @ org.springframework.beans.beanwrapperimpl.convertifnecessary(beanwrapperimpl.java:476) @ org.springframework.beans.beanwrapperimpl.convertforproperty(beanwrapperimpl.java:512) @ org.springframework.beans.beanwrapperimpl.convertforproperty(beanwrapperimpl.java:506) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.convertforproperty(abstractautowirecapablebeanfactory.java:1523) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.applypropertyvalues(abstractautowirecapablebeanfactory.java:1482) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.populatebean(abstractautowirecapablebeanfactory.java:1222) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:537) ... 11 more caused by: java.lang.illegalstateexception: cannot convert value of type [java.util.arraylist] required type [java.awt.list] property 'examplelist': no matching editors or conversion strategy found @ org.springframework.beans.typeconverterdelegate.convertifnecessary(typeconverterdelegate.java:287) @ org.springframework.beans.beanwrapperimpl.convertifnecessary(beanwrapperimpl.java:461) ... 17 more
look closely @ part of error message:
cannot convert value of type [java.util.arraylist] required type [java.awt.list] property 'examplelist'
you have imported wrong list
in code. change this:
import java.awt.list;
to this:
import java.util.list;
Comments
Post a Comment