Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error creating bean with name 'waffleNegotiateSecurityFilter': Requested bean is currently in creation: Is there an unresolvable circular reference? #476

Closed
rboughani opened this issue Jan 24, 2017 · 6 comments

Comments

@rboughani
Copy link

rboughani commented Jan 24, 2017

Any one knewn about this error message,

Caused by: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webSecurityConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private waffle.spring.NegotiateSecurityFilter fr.cc.suivireco.general.configuration.WebSecurityConfig.securityFilter; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'waffleNegotiateSecurityFilter': Requested bean is currently in creation: Is there an unresolvable circular reference?
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:295) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:149) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:129) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:85) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5261) ~[catalina.jar:8.0.35]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) [catalina.jar:8.0.35]
... 6 common frames omitted
     Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webSecurityConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private waffle.spring.NegotiateSecurityFilter fr.cc.suivireco.general.configuration.WebSecurityConfig.securityFilter; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'waffleNegotiateSecurityFilter': Requested bean is currently in creation: Is there an unresolvable circular reference?
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.boot.context.embedded.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:232) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.embedded.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:180) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.embedded.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:175) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.embedded.ServletContextInitializerBeans.addAdaptableBeans(ServletContextInitializerBeans.java:157) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.embedded.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:78) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getServletContextInitializerBeans(EmbeddedWebApplicationContext.java:235) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.selfInitialize(EmbeddedWebApplicationContext.java:222) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.access$000(EmbeddedWebApplicationContext.java:85) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext$1.onStartup(EmbeddedWebApplicationContext.java:207) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:162) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
... 17 common frames omitted
     Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private waffle.spring.NegotiateSecurityFilter fr.cc.suivireco.general.configuration.WebSecurityConfig.securityFilter; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'waffleNegotiateSecurityFilter': Requested bean is currently in creation: Is there an unresolvable circular reference?
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
... 44 common frames omitted
    Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'waffleNegotiateSecurityFilter': Requested bean is currently in creation: Is there an unresolvable circular reference?
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.beforeSingletonCreation(DefaultSingletonBeanRegistry.java:347) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1199) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
... 46 common frames omitted

My Waffle configuration is like

 package fr.cc.suivireco.general.configuration;

 import java.util.ArrayList;
 import java.util.List;

 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.core.annotation.Order;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
 import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
 import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
 import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;

 import waffle.servlet.spi.NegotiateSecurityFilterProvider;
 import waffle.servlet.spi.SecurityFilterProvider;
 import waffle.servlet.spi.SecurityFilterProviderCollection;
 import waffle.spring.NegotiateSecurityFilter;
 import waffle.spring.NegotiateSecurityFilterEntryPoint;
 import waffle.spring.WindowsAuthenticationProvider;
 import waffle.windows.auth.impl.WindowsAuthProviderImpl;

 /**
    * Security configuration based on {@link WebSecurityConfigurerAdapter}. This configuration is by purpose designed most
    * simple for two channels of authentication: simple login form and rest-url.
    *
    * @author hohwille, marcorose
    */
    @Configuration
    @EnableWebSecurity
    @Order(1)
     public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

     @Autowired
      private NegotiateSecurityFilterEntryPoint authenticationEntryPoint;

     @Autowired
     private NegotiateSecurityFilter securityFilter;

     @Autowired
      public WindowsAuthenticationProvider windowsAuthenticationProvider;

      @Override
      protected void configure(final HttpSecurity http) throws Exception {

          http.authorizeRequests().anyRequest().authenticated().and()
                   .addFilterBefore(this.securityFilter, BasicAuthenticationFilter.class).httpBasic()
                   .authenticationEntryPoint(this.authenticationEntryPoint).and()
                   .authenticationProvider(this.windowsAuthenticationProvider); // Set authentication provider here
                   // .formLogin().authenticationDetailsSource(waffleAuthenticationDetailsSource);

          }

    // Waffle Spring Security Beans
  @Bean
  public WindowsAuthProviderImpl windowsAuthProvider() {

               return new WindowsAuthProviderImpl();
  }

 @Bean
 @Autowired
 public NegotiateSecurityFilterProvider negotiateSecurityFilterProvider(
        final WindowsAuthProviderImpl windowsAuthProvider) {

        return new NegotiateSecurityFilterProvider(windowsAuthProvider);
  }

 @Bean
 @Autowired
 public SecurityFilterProviderCollection waffleSecurityFilterProviderCollection(
       final NegotiateSecurityFilterProvider negotiateSecurityFilterProvider) {

        final List<SecurityFilterProvider> securityFilterProviders = new ArrayList<SecurityFilterProvider>();
        securityFilterProviders.add(negotiateSecurityFilterProvider);
       return new SecurityFilterProviderCollection(securityFilterProviders.toArray(new SecurityFilterProvider[]   {}));
 }

@Bean
@Autowired
public NegotiateSecurityFilterEntryPoint negotiateSecurityFilterEntryPoint(
    final SecurityFilterProviderCollection securityFilterProviderCollection) {

    final NegotiateSecurityFilterEntryPoint negotiateSecurityFilterEntryPoint = new NegotiateSecurityFilterEntryPoint();
    negotiateSecurityFilterEntryPoint.setProvider(securityFilterProviderCollection);
    return negotiateSecurityFilterEntryPoint;
}

 @Bean
 @Autowired
 public NegotiateSecurityFilter waffleNegotiateSecurityFilter(
       final SecurityFilterProviderCollection securityFilterProviderCollection) {

       final NegotiateSecurityFilter negotiateSecurityFilter = new NegotiateSecurityFilter();
       negotiateSecurityFilter.setProvider(securityFilterProviderCollection);
       return negotiateSecurityFilter;
  }

 // @Bean
 // public WaffleAuthenticationDetailsSource waffleAuthenticationDetailsSource() {
 //
 // return new WaffleAuthenticationDetailsSource();
 // }

@Bean
@Autowired
public WindowsAuthenticationProvider windowsAuthenticationProvider(
    final WindowsAuthProviderImpl windowsAuthProvider) {

    WindowsAuthenticationProvider provider = new WindowsAuthenticationProvider();
    provider.setAuthProvider(windowsAuthProvider);
    return provider;
 }
}
@hazendaz
Copy link
Member

I assume you are using springboot based on configuring filter this way. Is that correct? If so, I think some docs have been made available recently on how to deal with spring boot but we don't officially support it yet. Any help in that area would be appreciated.

@rboughani
Copy link
Author

Yes, i use spring boot, if i can help with any think, i'll be happy,
thank you for this great work

@hazendaz
Copy link
Member

look through our docs and look in issues as I'm sure someone left reference to a possibly close working springboot version. I haven't myself tried to configure via spring boot yet but it's eventually planned. Not sure how much I can help right now but will leave this open in case someone else in the community can assist.

@mgoldgeier
Copy link
Contributor

@darkmanAmazigh I have a very simple Spring Boot + Waffle demo project here: https://github.com/mgoldgeier/waffle-spring-boot-demo

It should start up correctly, but I have noticed occasion problems when when using Spring Boot with Waffle through Internet Explorer. (I have not tried Edge).

@rboughani
Copy link
Author

can i use the spring-waffle in localhost mode or just after deployement ?

@hazendaz
Copy link
Member

hazendaz commented Jan 9, 2020

Closing issue as spring boot support has been available for some time and working well.

@hazendaz hazendaz closed this as completed Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants