java - Sporadic NoSuchBeanDefinitionException when trying to autowire field -
i've application-config.xml defined follows,
... <beans> <bean id="servicefactory" class="com.example.myservicefactory" /> <bean id="myaction" class="com.example.myaction" scope="request"> <aop:scoped-proxy/> </bean> <bean id="myservice" class="com.example.myservice" factory-bean="servicefactory" factory-method="getservice"> <constructor-arg type="java.lang.string" value="myserviceconfig" /> </bean> </beans> ...
as can see, 'myaction' bean request scoped , in myaction file i've following.
public class myaction { @autowired protected myservice myservice; } ...
sometimes, not always, see autowiring of dependency myservice fails. can't figure out if has in way way i've defined in application-context.xml or if has else. me out here?
edit1:
spring log says
org.springframework.beans.factory.beancreationexception: error creating bean name 'myaction': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: protected com.example.myservice; nested exception org.springframework.beans.factory.nosuchbeandefinitionexception: no matching bean of type [com.example.myservice] found dependency: expected @ least 1 bean qualifies autowire candidate dependency. dependency annotations: {@org.springframework.beans.factory.annotation.autowired(required=true)} @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor.postprocesspropertyvalues(autowiredannotationbeanpostprocessor.java:287) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.populatebean(abstractautowirecapablebeanfactory.java:1106) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:517) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:456) @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:294) @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:225) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:291) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:193) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:585) @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:913) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:464) @ org.springframework.web.context.contextloader.configureandrefreshwebapplicationcontext(contextloader.java:384) @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:283) @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:111) @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4723) @ org.apache.catalina.core.standardcontext$1.call(standardcontext.java:5226) @ org.apache.catalina.core.standardcontext$1.call(standardcontext.java:5221) @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:334) @ java.util.concurrent.futuretask.run(futuretask.java:166) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1110) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:603) @ java.lang.thread.run(thread.java:722)
Comments
Post a Comment