title: Java Spring Security exception
body: <p>I get exception <code>No bean named 'springSecurityFilterChain' is defined</code>, when start web app, but not understand why. My configurations:</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  @EnableGlobalMethodSecurity(securedEnabled = true)
  public class SecurityConfig extends WebSecurityConfigurerAdapter {
      @Inject private TokenProvider tokenProvider;
      @Inject private CustomUserDetailsService userDetailsService;
      @Inject private DefaultEntryPoint defaultEntryPoint;
      @Inject
      public void registerGlobalAuthentication(AuthenticationManagerBuilder auth) throws Exception {
          auth
                  .userDetailsService(userDetailsService)
                  .passwordEncoder(passwordEncoder());
      }
  
      @Bean
      @Override
      public AuthenticationManager authenticationManagerBean() throws Exception {
          return super.authenticationManagerBean();
      }
  
      private XAuthTokenConfigurer securityConfigurerAdapter() {
          return new XAuthTokenConfigurer(userDetailsService, tokenProvider);
      }
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http
                  .sessionManagement()
                  .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
          .and()
                  .exceptionHandling()
                  .authenticationEntryPoint(defaultEntryPoint)
          .and()
                  .apply(securityConfigurerAdapter())
          .and()
                .csrf().disable()
                  .authorizeRequests()
                  .antMatchers("/", "/login", "/logout").permitAll()
                  .antMatchers("/feed").authenticated()
                  .anyRequest().authenticated();
      }
      @Bean
      public TokenProvider tokenProvider(){
          String secret = "secret";
          int validityInSeconds = 172800;
          return new TokenProvider(secret, validityInSeconds, 172800);
      }
      @Override
      public void configure(WebSecurity web) throws Exception {
          web.ignoring()
                  .antMatchers("/favicon.ico")
                  .antMatchers("/resources/**")
                  .antMatchers("/userresources/**");
      }
      @Bean
      public PasswordEncoder passwordEncoder(){
          return new BCryptPasswordEncoder();
      }
  }
  </code></pre>
  
  <p>This security initializer configurations:</p>
  
  <pre><code>@Configuration
  public class SecurityInit extends AbstractSecurityWebApplicationInitializer {
  }
  </code></pre>
  
  <p>And application initializer:</p>
  
  <pre><code>@Configuration
  public class ApplicationInitializer implements WebApplicationInitializer {
  
      public void onStartup(ServletContext servletContext) throws ServletException {
          AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
          ctx.register(WebMvcConfig.class);
          ctx.register(DatabaseConfig.class);
          ctx.register(SecurityConfig.class);
  
          ServletRegistration.Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
  
          ctx.setServletContext(servletContext);
  
          servlet.setLoadOnStartup(1);
          servlet.addMapping("/");
  
      }
  }
  </code></pre>
  
  <p>What have I missed?</p>