title: Spring Boot 1.0.0-RC4 starts with multiple EmbeddedServletContainerFactory instances
body: <p>I am looking to override the default EmbeddedServletContainerFactory as documented <a href="http://projects.spring.io/spring-boot/docs/spring-boot/README.html" rel="nofollow" title="here">here</a> in order to set up SSL.  The <a href="http://projects.spring.io/spring-boot/docs/docs/howto.html" rel="nofollow">old docs</a> (from RC1 days) said to override the Customizer and that worked great until I upgraded today, changed the implementation to follow the new convention.  </p>
  
  <pre><code>@Configuration
  public class ContainerConfig {
  
  @Bean
  public EmbeddedServletContainerFactory servletContainer() {
    TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
    factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
  
    @Override
    public void customize(Connector connector) {
  
      connector.setPort(8443);
      connector.setSecure(true);
      connector.setScheme("https");
      connector.setAttribute("keyAlias", "tomcat");
      connector.setAttribute("keystorePass", "changeit");
      try {
        connector.setAttribute("keystoreFile", ResourceUtils.getFile("src/ssl/tomcat.keystore").getAbsolutePath());
      } catch (FileNotFoundException e) {
        throw new IllegalStateException("Cannot load keystore", e);
      }
        connector.setAttribute("clientAuth", "false");
        connector.setAttribute("sslProtocol", "TLS");
        connector.setAttribute("SSLEnabled", true);
      }
  
    });
  
    factory.setSessionTimeout(10, TimeUnit.MINUTES);
  
    return factory;
  }
  </code></pre>
  
  <p>The source code in Boot (EmbeddedServletContainerAutoConfiguration) indicates that if it does find my bean, it will not register the default:</p>
  
  <pre><code>@ConditionalOnMissingBean(value = EmbeddedServletContainerFactory.class, search = SearchStrategy.CURRENT)
  </code></pre>
  
  <p>However it appears to register anyhow.  Does anybody else have this working?  Here is the stack:</p>
  
  <blockquote>
    <p>Exception in thread "main"
    org.springframework.context.ApplicationContextException: Unable to
    start embedded container; nested exception is
    org.springframework.context.ApplicationContextException: Unable to
    start EmbeddedWebApplicationContext due to multiple
    EmbeddedServletContainerFactory beans :
    servletContainer,tomcatEmbeddedServletContainerFactory    at
    org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:135)
      at
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
      at
    org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
      at
    org.springframework.boot.SpringApplication.refresh(SpringApplication.java:619)
      at
    org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
      at
    org.springframework.boot.SpringApplication.run(SpringApplication.java:880)
      at
    org.springframework.boot.SpringApplication.run(SpringApplication.java:869)
      at
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)     at
    com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
    Caused by: org.springframework.context.ApplicationContextException:
    Unable to start EmbeddedWebApplicationContext due to multiple
    EmbeddedServletContainerFactory beans :
    servletContainer,tomcatEmbeddedServletContainerFactory    at
    org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:190)
      at
    org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:158)
      at
    org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)
      ... 12 more</p>
  </blockquote>
  
  <p>I have created a <a href="https://github.com/hoserdude/spring-boot-sample-tomcat-ssl" rel="nofollow">GitHub repo</a> that mashes up the Tomcat and Websocket samples from the Spring Boot project, and applies this configuration.  </p>