Search in sources :

Example 16 with WebServerException

use of org.springframework.boot.web.server.WebServerException in project sofa-ark by alipay.

the class ArkTomcatWebServer method start.

@Override
public void start() throws WebServerException {
    synchronized (this.monitor) {
        if (this.started) {
            return;
        }
        try {
            addPreviouslyRemovedConnectors();
            this.tomcat.getConnector();
            checkThatConnectorsHaveStarted();
            this.started = true;
            logger.info("Tomcat started on port(s): " + getPortsDescription(true) + " with context path '" + getContextPath() + "'");
        } catch (ConnectorStartFailedException ex) {
            stopSilently();
            throw ex;
        } catch (Exception ex) {
            throw new WebServerException("Unable to start embedded Tomcat server", ex);
        } finally {
            Context context = findContext();
            ContextBindings.unbindClassLoader(context, context.getNamingToken(), getClass().getClassLoader());
        }
    }
}
Also used : Context(org.apache.catalina.Context) WebServerException(org.springframework.boot.web.server.WebServerException) LifecycleException(org.apache.catalina.LifecycleException) WebServerException(org.springframework.boot.web.server.WebServerException) NamingException(javax.naming.NamingException) ConnectorStartFailedException(org.springframework.boot.web.embedded.tomcat.ConnectorStartFailedException) ConnectorStartFailedException(org.springframework.boot.web.embedded.tomcat.ConnectorStartFailedException)

Example 17 with WebServerException

use of org.springframework.boot.web.server.WebServerException in project sofa-ark by alipay.

the class ArkTomcatWebServer method stop.

@Override
public void stop() throws WebServerException {
    synchronized (this.monitor) {
        boolean wasStarted = this.started;
        try {
            this.started = false;
            try {
                stopContext();
                stopTomcatIfNecessary();
            } catch (Throwable ex) {
            // swallow and continue
            }
        } catch (Exception ex) {
            throw new WebServerException("Unable to stop embedded Tomcat", ex);
        } finally {
            if (wasStarted) {
                containerCounter.decrementAndGet();
            }
        }
    }
}
Also used : WebServerException(org.springframework.boot.web.server.WebServerException) LifecycleException(org.apache.catalina.LifecycleException) WebServerException(org.springframework.boot.web.server.WebServerException) NamingException(javax.naming.NamingException) ConnectorStartFailedException(org.springframework.boot.web.embedded.tomcat.ConnectorStartFailedException)

Aggregations

WebServerException (org.springframework.boot.web.server.WebServerException)17 PortInUseException (org.springframework.boot.web.server.PortInUseException)7 IOException (java.io.IOException)6 URL (java.net.URL)6 NamingException (javax.naming.NamingException)6 LifecycleException (org.apache.catalina.LifecycleException)6 Context (org.apache.catalina.Context)4 ConnectorStartFailedException (org.springframework.boot.web.embedded.tomcat.ConnectorStartFailedException)3 InputStream (java.io.InputStream)2 BindException (java.net.BindException)2 KeyStore (java.security.KeyStore)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ServletException (javax.servlet.ServletException)2 Undertow (io.undertow.Undertow)1 HttpHandler (io.undertow.server.HttpHandler)1 HttpServerExchange (io.undertow.server.HttpServerExchange)1 GracefulShutdownHandler (io.undertow.server.handlers.GracefulShutdownHandler)1 Closeable (java.io.Closeable)1