java - After new Controller created i'm getting "Injection of autowired dependencies failed" in Spring MVC , Hibernate -
i have added new controller in spring mvc project , added annotations below ...but here while running project i'm getting 404 exception , in console i'm getting exception below ...i'm confused figure out issue...
here controller:
@controller @requestmapping("/escprojectprogstatuscontroller") public class escprojectprogstatuscontroller { @autowired escprojectprogstatusservice escprojectprogstatusservice; @requestmapping(value = "/fetchunitnamedropdown") public @responsebody string fetchunitnamedropdown(httpservletrequest request){ string strunitnames = ""; string strprojectid = request.getparameter("projectid")==null?"":request.getparameter("projectid"); try { strunitnames = escprojectprogstatusservice.fetchunitnamefromprojectid(strprojectid); } catch (exception e) { //logger.error(e); throw e; } return strunitnames.tostring(); } }
service impl:
@service("escprojectprogstatusservices") @transactional public class escprojectprogstatusserviceimpl implements escprojectprogstatusservice { @autowired escprojectprogstatusdao escprojectprogstatusdao; @override public string fetchunitnamefromprojectid(string strprojectid){ jsonarray jsonarr = new jsonarray(); jsonobject jsonobj = null; list<projectunit> listprojectunit = null; try{ listprojectunit = (list<projectunit>)escprojectprogstatusdao.fetchunitnamefromprojectid(strprojectid); if(listprojectunit!=null){ for(projectunit projectunit :listprojectunit){ jsonobj = new jsonobject(); jsonobj.put("unittype", projectunit.getunittype()); jsonobj.put("unitname", projectunit.getunitname()); jsonarr.add(jsonobj); } } }catch(exception e){ //logger.error(e); } return jsonarr.tostring(); } }
dao impl:
@repository("escprojectprogstatusdao") public class escprojectprogstatusdaoimpl implements escprojectprogstatusdao { @autowired private sessionfactory sessionfactory; @override public list<projectunit> fetchunitnamefromprojectid(string strprojectid){ list<projectunit> listprojectunit = null; try { session session = sessionfactory.getcurrentsession(); criteria criteria = session.createcriteria(projectunit.class); criteria.add(restrictions.eq("merchantproductid", strprojectid)); listprojectunit=criteria.list(); }catch(exception e){ //logger.error(e); } return listprojectunit; } }
exception , stack trace:
severe: exception sending context initialized event listener instance of class org.springframework.web.context.contextloaderlistener org.springframework.beans.factory.beancreationexception: error creating bean name 'escprojectprogstatuscontroller': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: com.interland.b2b.service.escprojectprogstatusservice com.interland.b2b.controller.escprojectprogstatuscontroller.escprojectprogstatusservice; nested exception org.springframework.beans.conversionnotsupportedexception: failed convert value of type 'java.lang.string' required type 'com.interland.b2b.service.escprojectprogstatusservice'; nested exception java.lang.illegalstateexception: cannot convert value of type [java.lang.string] required type [com.interland.b2b.service.escprojectprogstatusservice]: no matching editors or conversion strategy found @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor.postprocesspropertyvalues(autowiredannotationbeanpostprocessor.java:334) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.populatebean(abstractautowirecapablebeanfactory.java:1208) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:537) @ 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:759) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:480) @ org.springframework.web.context.contextloader.configureandrefreshwebapplicationcontext(contextloader.java:434) @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:306) @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:106) @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4973) @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5467) @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150) @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1559) @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1549) @ java.util.concurrent.futuretask.run(unknown source) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ java.lang.thread.run(unknown source) caused by: org.springframework.beans.factory.beancreationexception: not autowire field: com.interland.b2b.service.escprojectprogstatusservice com.interland.b2b.controller.escprojectprogstatuscontroller.escprojectprogstatusservice; nested exception org.springframework.beans.conversionnotsupportedexception: failed convert value of type 'java.lang.string' required type 'com.interland.b2b.service.escprojectprogstatusservice'; nested exception java.lang.illegalstateexception: cannot convert value of type [java.lang.string] required type [com.interland.b2b.service.escprojectprogstatusservice]: no matching editors or conversion strategy found @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor$autowiredfieldelement.inject(autowiredannotationbeanpostprocessor.java:561) @ org.springframework.beans.factory.annotation.injectionmetadata.inject(injectionmetadata.java:88) @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor.postprocesspropertyvalues(autowiredannotationbeanpostprocessor.java:331) ... 22 more caused by: org.springframework.beans.conversionnotsupportedexception: failed convert value of type 'java.lang.string' required type 'com.interland.b2b.service.escprojectprogstatusservice'; nested exception java.lang.illegalstateexception: cannot convert value of type [java.lang.string] required type [com.interland.b2b.service.escprojectprogstatusservice]: no matching editors or conversion strategy found @ org.springframework.beans.typeconvertersupport.doconvert(typeconvertersupport.java:74) @ org.springframework.beans.typeconvertersupport.convertifnecessary(typeconvertersupport.java:54) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.doresolvedependency(defaultlistablebeanfactory.java:961) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.resolvedependency(defaultlistablebeanfactory.java:942) @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor$autowiredfieldelement.inject(autowiredannotationbeanpostprocessor.java:533) ... 24 more caused by: java.lang.illegalstateexception: cannot convert value of type [java.lang.string] required type [com.interland.b2b.service.escprojectprogstatusservice]: no matching editors or conversion strategy found @ org.springframework.beans.typeconverterdelegate.convertifnecessary(typeconverterdelegate.java:287) @ org.springframework.beans.typeconverterdelegate.convertifnecessary(typeconverterdelegate.java:124) @ org.springframework.beans.typeconvertersupport.doconvert(typeconvertersupport.java:61) ... 28 more
can please me rid of problem..many in advance....
in escprojectprogstatusserviceimpl
class remove string parameter of @service
annotation:
before:
@service("escprojectprogstatusservices")
after:
@service
Comments
Post a Comment