private synchronized void initialize() throws EmbeddedServletContainerException { try { addInstanceIdToEngineName(); // Remove service connectors to that protocol binding doesn't happen yet removeServiceConnectors(); // Start the server to trigger initialization listeners this.tomcat.start(); // We can re-throw failure exception directly in the main thread rethrowDeferredStartupExceptions(); // Unlike Jetty, all Tomcat threads are daemon threads. We create a // blocking non-daemon to stop immediate shutdown startDaemonAwaitThread(); if (LifecycleState.FAILED.equals(this.tomcat.getConnector().getState())) { this.tomcat.stop(); throw new IllegalStateException("Tomcat connector in failed state"); } } catch (Exception ex) { throw new EmbeddedServletContainerException("Unable to start embedded Tomcat", ex); } }
@Override public void start() throws EmbeddedServletContainerException { addPreviouslyRemovedConnectors(); Connector connector = this.tomcat.getConnector(); if (connector != null && this.autoStart) { startConnector(connector); } // Ensure process isn't left running if it actually failed to start if (LifecycleState.FAILED.equals(this.tomcat.getConnector().getState())) { try { this.tomcat.stop(); } catch (LifecycleException e) { } throw new IllegalStateException("Tomcat connector in failed state"); } }