PDA

View Full Version : org.springframework.beans.factory.UnsatisfiedDepen dencyException



jineshk
Nov 4th, 2008, 09:11 AM
Hi
I am upgrading the application from spring 2.0.6 to 2.5.5 version.
I got it compiled and run the junit testcases using maven without any issues.
When i deployed the same to the weblogic 10.0 i started getting
below stack trace. Any help from you guys are appreciated.


2008-11-04 09:45:10,404 [org.springframework.web.context.ContextLoader:ERRO R]
Context initialization failed
----------------------------------------------------------------
org.springframework.beans.factory.UnsatisfiedDepen dencyException: Error creating bean with name 'methodSecurityAdvisor' defined in ServletContext resource [/WEB-INF/applicationContext-acegi.xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.acegisecurity.intercept.method.aopalliance.Met hodSecurityInterceptor]: There are 0 beans of type [org.acegisecurity.intercept.method.aopalliance.Met hodSecurityInterceptor] available for autowiring: []. There should have been exactly 1 to be able to autowire constructor of bean 'methodSecurityAdvisor'.
at org.springframework.beans.factory.support.Construc torResolver.createArgumentArray(ConstructorResolve r.java:474)
at org.springframework.beans.factory.support.Construc torResolver.autowireConstructor(ConstructorResolve r.java:153)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.autowireConstructor(Abs tractAutowireCapableBeanFactory.java:799)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:717)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:384)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 51)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:156)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.aop.framework.autoproxy.BeanFa ctoryAdvisorRetrievalHelper.findAdvisorBeans(BeanF actoryAdvisorRetrievalHelper.java:87)
at org.springframework.aop.framework.autoproxy.Abstra ctAdvisorAutoProxyCreator.findCandidateAdvisors(Ab stractAdvisorAutoProxyCreator.java:96)
at org.springframework.aop.framework.autoproxy.Abstra ctAdvisorAutoProxyCreator.findEligibleAdvisors(Abs tractAdvisorAutoProxyCreator.java:83)
at org.springframework.aop.framework.autoproxy.Abstra ctAdvisorAutoProxyCreator.getAdvicesAndAdvisorsFor Bean(AbstractAdvisorAutoProxyCreator.java:66)
at org.springframework.aop.framework.autoproxy.Abstra ctAutoProxyCreator.postProcessAfterInitialization( AbstractAutoProxyCreator.java:296)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyBeanPostProcessors AfterInitialization(AbstractAutowireCapableBeanFac tory.java:312)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1180)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:425)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 51)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:156)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.context.support.AbstractApplic ationContext.getBean(AbstractApplicationContext.ja va:733)
at org.springframework.context.support.AbstractApplic ationContext.registerBeanPostProcessors(AbstractAp plicationContext.java:511)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:337)
at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:244)
at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:187)
at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 49)
at weblogic.servlet.internal.EventsManager$FireContex tListenerAction.run(EventsManager.java:458)
at weblogic.security.acl.internal.AuthenticatedSubjec t.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Un known Source)
at weblogic.servlet.internal.EventsManager.notifyCont extCreatedEvent(EventsManager.java:168)
at weblogic.servlet.internal.WebAppServletContext.pre loadResources(WebAppServletContext.java:1721)
at weblogic.servlet.internal.WebAppServletContext.sta rt(WebAppServletContext.java:2890)
at weblogic.servlet.internal.WebAppModule.startContex ts(WebAppModule.java:948)
at weblogic.servlet.internal.WebAppModule.start(WebAp pModule.java:353)
at weblogic.application.internal.flow.ModuleStateDriv er$3.next(ModuleStateDriver.java:204)
at weblogic.application.utils.StateMachineDriver.next State(StateMachineDriver.java:26)
at weblogic.application.internal.flow.ModuleStateDriv er.start(ModuleStateDriver.java:60)
at weblogic.application.internal.flow.ScopedModuleDri ver.start(ScopedModuleDriver.java:200)
at weblogic.application.internal.flow.ModuleListenerI nvoker.start(ModuleListenerInvoker.java:117)
at weblogic.application.internal.flow.ModuleStateDriv er$3.next(ModuleStateDriver.java:204)
at weblogic.application.utils.StateMachineDriver.next State(StateMachineDriver.java:26)
at weblogic.application.internal.flow.ModuleStateDriv er.start(ModuleStateDriver.java:60)
at weblogic.application.internal.flow.StartModulesFlo w.activate(StartModulesFlow.java:26)
at weblogic.application.internal.BaseDeployment$2.nex t(BaseDeployment.java:635)
at weblogic.application.utils.StateMachineDriver.next State(StateMachineDriver.java:26)
at weblogic.application.internal.BaseDeployment.activ ate(BaseDeployment.java:212)
at weblogic.application.internal.DeploymentStateCheck er.activate(DeploymentStateChecker.java:154)
at weblogic.deploy.internal.targetserver.AppContainer Invoker.activate(AppContainerInvoker.java:80)
at weblogic.deploy.internal.targetserver.BasicDeploym ent.activate(BasicDeployment.java:182)
at weblogic.deploy.internal.targetserver.BasicDeploym ent.activateFromServerLifecycle(BasicDeployment.ja va:359)
at weblogic.management.deploy.internal.DeploymentAdap ter$1.doActivate(DeploymentAdapter.java:51)
at weblogic.management.deploy.internal.DeploymentAdap ter.activate(DeploymentAdapter.java:196)
at weblogic.management.deploy.internal.AppTransition$ 2.transitionApp(AppTransition.java:30)
at weblogic.management.deploy.internal.ConfiguredDepl oyments.transitionApps(ConfiguredDeployments.java: 233)
at weblogic.management.deploy.internal.ConfiguredDepl oyments.activate(ConfiguredDeployments.java:169)
at weblogic.management.deploy.internal.ConfiguredDepl oyments.deploy(ConfiguredDeployments.java:123)
at weblogic.management.deploy.internal.DeploymentServ erService.resume(DeploymentServerService.java:173)
at weblogic.management.deploy.internal.DeploymentServ erService.start(DeploymentServerService.java:89)
at weblogic.t3.srvr.SubsystemRequest.run(SubsystemReq uest.java:64)
at weblogic.work.ExecuteThread.execute(ExecuteThread. java:200)
at weblogic.work.ExecuteThread.run(ExecuteThread.java :172)
<Nov 4, 2008 9:45:10 AM EST> <Warning> <HTTP> <BEA-101162> <User defined listener org.springframework.web.context.ContextLoaderListe ner failed: org.springframework.beans.factory.UnsatisfiedDepen dencyException: Error creating bean with name 'methodSecurityAdvisor' defined in ServletContext resource [/WEB-INF/applicationContext-acegi.xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.acegisecurity.intercept.method.aopalliance.Met hodSecurityInterceptor]: There are 0 beans of type [org.acegisecurity.intercept.method.aopalliance.Met hodSecurityInterceptor] available for autowiring: []. There should have been exactly 1 to be able to autowire constructor of bean 'methodSecurityAdvisor'..
org.springframework.beans.factory.UnsatisfiedDepen dencyException: Error creating bean with name 'methodSecurityAdvisor' defined in ServletContext resource [/WEB-INF/applicationContext-acegi.xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.acegisecurity.intercept.method.aopalliance.Met hodSecurityInterceptor]: There are 0 beans of type [org.acegisecurity.intercept.method.aopalliance.Met hodSecurityInterceptor] available for autowiring: []. There should have been exactly 1 to be able to autowire constructor of bean 'methodSecurityAdvisor'.
at org.springframework.beans.factory.support.Construc torResolver.createArgumentArray(ConstructorResolve r.java:474)
at org.springframework.beans.factory.support.Construc torResolver.autowireConstructor(ConstructorResolve r.java:153)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.autowireConstructor(Abs tractAutowireCapableBeanFactory.java:799)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:717)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:384)
Truncated. see log file for complete stacktrace
>
>

Thanks
jinesh

Joris Kuipers
Nov 4th, 2008, 01:07 PM
This forum is for the SpringSource dm Server, not for regular Spring apps running on WebLogic.
Your exception indicated that you're trying to autowire a bean called methodSecurityAdvisor that requires a bean of type MethodSecurityInterceptor as a constructor argument. However, such a bean is not defined, at least not in the application context(s) visible from the one that methodSecurityAdvisoris defined in.

jineshk
Nov 4th, 2008, 01:44 PM
Joris,

Thanks for the reply. but the same context file has no issue while deployment using spring 2.0.8. I upgraded the libraries and changes the schema to point to 2.5.5 related.
also adding the bean definition part from context.xml.

<bean id="attributes" class="org.acegisecurity.annotation.SecurityAnnotationAtt ributes" />

<bean id="objectDefinitionSource" class="org.acegisecurity.intercept.method.MethodDefinitio nAttributes">
<property name="attributes">
<ref local="attributes" />
</property>
</bean>

<!-- We don't validate config attributes, as it's unsupported by MethodDefinitionAttributes -->
<bean id="securityInterceptor" class="org.acegisecurity.intercept.method.aopalliance.Met hodSecurityInterceptor">
<property name="validateConfigAttributes"><value>false</value></property>
<property name="authenticationManager"><ref local="authenticationManager"/></property>
<property name="accessDecisionManager"><ref local="businessAccessDecisionManager"/></property>
<property name="afterInvocationManager"><ref local="afterInvocationManager"/></property>
<property name="objectDefinitionSource"><ref local="objectDefinitionSource"/></property>
</bean>

<!--
AOP advisor that will automatically wire the MethodSecurityInterceptor (above)
into our services. The configuration attributes used are obtained
from the securityInterceptor.objectDefinitionSouce, which in the
above configuration is a JDK 5 Annotations Attributes-based source.
-->
<bean id="methodSecurityAdvisor"
class="org.acegisecurity.intercept.method.aopalliance.Met hodDefinitionSourceAdvisor">

<constructor-arg index="0" ref="securityInterceptor"/>

</bean>

Joris Kuipers
Nov 5th, 2008, 04:08 AM
When you say context.xml, do you really mean applicationContext-acegi.xml? Because that's the file that the error mentions.
It's weird, the config you're showing has an explicit constructor AND a matching dependency, but the error indicates that the constructor is autowired instead AND that the dependency cannot be resolved. It looks like the content you've shown isn't actually used at runtime, though it's hard to tell without additional info.

jineshk
Nov 5th, 2008, 08:49 AM
Hi,

Yes i meant the applicationcontext_acegi.xml.
when i changed the bean definition to constructor argument (as mentioned in my 2 nd post) the earlier mentioned error was gone and now i have very different stack trace.
----------------------------------------------------------------
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'methodSecurityAdvisor' defined in ServletContext resource [/WEB-INF/applicationContext-acegi.xml]: Cannot resolve reference to bean 'securityInterceptor' while setting constructor argument with index 0; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'securityInterceptor' defined in ServletContext resource [/WEB-INF/applicationContext-acegi.xml]: Cannot resolve reference to bean 'authenticationManager' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'authenticationManager' defined in ServletContext resource [/WEB-INF/applicationContext-acegi.xml]: Cannot resolve reference to bean 'daoAuthenticationProvider' while setting bean property 'providers' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'daoAuthenticationProvider' defined in ServletContext resource [/WEB-INF/applicationContext-acegi.xml]: Cannot resolve reference to bean 'crownUserDetailsSvc' while setting bean property 'userDetailsService'; Caused by:
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'userService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Class must not be null
Caused by:
java.lang.IllegalArgumentException: Class must not be null