title: How do I get Spring Boot Security and JBoss 7.1 to play nicely with each other?
body: <p>Versions:</p>
  
  <p>JBoss: 7.1
  Spring Boot: 1.4.1.RELEASE</p>
  
  <p>Starting a project from scratch and following the directions for securing a spring-boot app from here: <a href="https://spring.io/guides/gs/securing-web/" rel="nofollow">https://spring.io/guides/gs/securing-web/</a>, I get an application quick and easy that runs from <code>gradle clean bootRun</code>.</p>
  
  <p>But, when I build with <code>gradle clean war</code> and deploy to a JBoss 7.1 server, during startup it fails with the following:</p>
  
  <pre><code>2016-09-24 18:01:37,783 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/]] (MSC service thread 1-10)  | Exception starting filter springSecurityFilterChain: java.lang.InstantiationException: org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean$1
  at java.lang.Class.newInstance(Class.java:427) [rt.jar:1.8.0_101]
  at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:80) [jboss-as-web-7.1.2.Final.jar:7.1.2.Final]
  at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:72) [jboss-as-web-7.1.2.Final.jar:7.1.2.Final]
  at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:441) [jbossweb-fas.jar:fas-4]
  at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3269) [jbossweb-fas.jar:fas-4]
  at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873) [jbossweb-fas.jar:fas-4]
  at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:91) [jboss-as-web-7.1.2.Final.jar:7.1.2.Final]
  at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
  at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_101]
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_101]
  at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_101]
  
  Caused by: java.lang.NoSuchMethodException: org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean$1.&lt;init&gt;()
  at java.lang.Class.getConstructor0(Class.java:3082) [rt.jar:1.8.0_101]
  at java.lang.Class.newInstance(Class.java:412) [rt.jar:1.8.0_101]
  ... 11 more
  </code></pre>
  
  <p>I've been digging on this thing for a couple weeks and trying to attack it from a number of angles. I get a similar error when I skip the WebSecurity class together and instead do a @ImportResource("classpath:security-context.xml) (from another working project).  With a bit of tinkering I get it to behave again for <code>gradle bootRun</code> but deploying it to JBoss results in the same error.</p>
  
  <p>TIA.</p>
  
  <p>Significant code sections:</p>
  
  <p>build.gradle:</p>
  
  <pre><code>buildscript {
      ext {
          springBootVersion = '1.4.1.RELEASE'
      }
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
      }
  }
  
  apply plugin: 'java'
  apply plugin: 'eclipse-wtp'
  apply plugin: 'spring-boot'
  apply plugin: 'war'
  
  war {
      baseName = 'demo'
      version = '0.0.1-SNAPSHOT'
  }
  
  sourceCompatibility = 1.8
  targetCompatibility = 1.8
  
  ...
  
  dependencies {
      compile('org.springframework.boot:spring-boot-devtools')
      compile('org.springframework.boot:spring-boot-starter-security')
      compile('org.springframework.boot:spring-boot-starter-thymeleaf')
      compile('org.springframework.boot:spring-boot-starter-web')
  
      compile('org.slf4j:slf4j-api:1.7.5')
  
      providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
      testCompile('org.springframework.boot:spring-boot-starter-test')
  }
  </code></pre>
  
  <p>DemoApplication:</p>
  
  <pre class="lang-java prettyprint-override"><code>import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
  import org.springframework.boot.builder.SpringApplicationBuilder;
  import org.springframework.boot.web.support.SpringBootServletInitializer;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  
  @Configuration
  @ComponentScan
  @EnableAutoConfiguration
  public class DemoApplication extends SpringBootServletInitializer {
  
  @Override
  protected SpringApplicationBuilder configure(final SpringApplicationBuilder application) {
      return application.sources(SnapshotApiDemoApplication.class);
  }
  
  public static void main(final String[] args) {
      SpringApplication.run(SnapshotApiDemoApplication.class, args);
  }
  }
  </code></pre>
  
  <p>WebSecurityConfig:</p>
  
  <pre class="lang-java prettyprint-override"><code>import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
  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;
  
  @Configuration
  @EnableWebSecurity
  public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
  @Override
  protected void configure(final HttpSecurity http) throws Exception {
      http.authorizeRequests().antMatchers("/", "/home").permitAll().anyRequest().authenticated().and().formLogin()
              .loginPage("/login").permitAll().and().logout().permitAll();
  }
  
  @Autowired
  public void configureGlobal(final AuthenticationManagerBuilder auth) throws Exception {
      auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
  }
  }
  </code></pre>
  
  <p>application.yml:</p>
  
  <pre><code>spring:
    main:
      banner-mode: off
      application:
        name: snapshot
        debug: true
  
    server:
      version: UNKNOWN
      context-path: /
  </code></pre>
  
  <p>application.properties:</p>
  
  <pre><code>logger.level=DEBUG
  logger.handlers=FILE,CONSOLE
  
  handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
  handler.CONSOLE.properties=autoFlush
  handler.CONSOLE.level=INFO
  handler.CONSOLE.autoFlush=true
  handler.CONSOLE.formatter=PATTERN
  
  handler.FILE=org.jboss.logmanager.handlers.FileHandler
  handler.FILE.level=INFO
  handler.FILE.properties=autoFlush,fileName
  handler.FILE.autoFlush=true
  handler.FILE.fileName=demo.log
  handler.FILE.formatter=PATTERN
  
  formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
  formatter.PATTERN.properties=pattern
  formatter.PATTERN.pattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n
  </code></pre>