UDIT JOSHI
UDIT JOSHI

Reputation: 1388

UnsatisfiedDependencyException when migrating spring project to 2.x

I am trying to upgrade the spring boot project from 1.5.x to 2.1.3 everything is compiled file but it gives run time exception

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ldapConfig': Unsatisfied dependency expressed through field 'ldapParams'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapParams': Injection of autowired dependencies failed; nested exception is java.lang.StackOverflowError at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1395) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)

Upvotes: 1

Views: 512

Answers (1)

Karol Dowbecki
Karol Dowbecki

Reputation: 44970

Most likely one of the dependent beans needed by either ldapConfig or ldapParams beans has a prototype scope and a cyclic dependency (e.g. ldapConfig requires ldapParams but ldapParams requires ldapConfig). This results in new beans being created recursively until StackOverflowError is thrown.

Review your LDAP beans and remove cyclic dependency and prototype scope (if not needed).

Upvotes: 0

Related Questions