title: Why doesn't Tomcat start the connector when I start the server itself?
body: <p>I have code to embed Tomcat which looks like this:</p>
  
  <pre><code>public void start()
  {
      final Tomcat tomcat = createTomcat();
  
      try
      {
          tomcat.start();
      }
      catch (Exception e)
      {
          throw new RuntimeException("Failed to start web server", e);
      }
  
      this.tomcat = tomcat;
  }
  
  private Tomcat createTomcat()
  {
      Tomcat tomcat = new Tomcat();
      tomcat.setBaseDir(FileUtils.getTempDirectory().getAbsolutePath());
  
      tomcat.setConnector(createConnector());
  
      // ... eliding the webapp, session, access log setup ...
  
      return tomcat;
  }
  
  private Connector createConnector()
  {
      Connector connector = new Connector();
      connector.setPort(context.getWebServerPort());
      connector.setScheme("https");
      connector.setSecure(true);
  
      //prepareKeyStore(context.getListeningHost());
  
      connector.setAttribute("address", context.getListeningAddress());
      connector.setAttribute("SSLEnabled", true);
  
      // Bind on start() instead of init() so that the port is closed faster on shutdown
      // I still have another problem where stop() seems to return before shutdown is
      // truly complete!
      connector.setAttribute("bindOnInit", false);
  
      connector.setAttribute("keystoreFile", "/my/keystore");
      connector.setAttribute("keystorePass", "password");
      connector.setAttribute("clientAuth", "false");
      connector.setAttribute("sslProtocol", "TLS");
      connector.setAttribute("keyAlias", context.getListeningHost());
      connector.setAttribute("keyPass", "password");
  
      return connector;
  }
  </code></pre>
  
  <p>When this runs, Tomcat doesn't start listening on any port. I poked around and found that the connector was still in state NEW.</p>
  
  <p>Why doesn't Tomcat start it when I start Tomcat itself?</p>
  
  <p>The same occurs on stop() and destroy(). Neither of them appear to call it.</p>
  
  <p>No errors occur, and if I later call <code>tomcat.getConnector().start()</code>, it appears to succeed and make the service contactable.</p>