Spring Security Java configuration without Spring/Spring MVC
<p>There are a few similar looking questions in stackoverflow, but none of them seems to answer it clearly.</p>

<p>I'm adding Spring Security to an existing web application which doesn't use Spring or Spring MVC. I only need the Spring Security filter, and nothing else (no MVC etc). My XML based configuration works perfectly fine, but not the Java configuration. I was mostly following <a href="http://docs.spring.io/autorepo/docs/spring-security/4.1.x/reference/htmlsingle/#abstractsecuritywebapplicationinitializer-without-existing-spring" rel="nofollow">this guide</a>. For some reason the Spring Security filter doesn't seem to be available.</p>

<p>So the security configuration is as below - <code>SecurityConfig.java</code></p>

<pre><code>@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
    }
}
</code></pre>

<p>And the <code>SecurityWebApplicationInitializer.java</code></p>

<pre><code>public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer {
    public SecurityWebApplicationInitializer() {
        super(SecurityConfig.class);
    }
}
</code></pre>

<p>What am I doing wrong above? How does the <code>SecurityWebApplicationInitializer</code> gets initialized and load the security config? Is the initialization part of the servlet context loading - which I have to explicitly define somewhere?</p>