use of org.springframework.boot.web.server.WebServerException in project spring-boot by spring-projects.
the class JettyWebServer method initialize.
private void initialize() {
synchronized (this.monitor) {
try {
// Cache and clear the connectors to prevent requests being handled before
// the application context is ready
this.connectors = this.server.getConnectors();
this.server.setConnectors(null);
// Start the server so that the ServletContext is available
this.server.start();
this.server.setStopAtShutdown(false);
} catch (Exception ex) {
// Ensure process isn't left running
stopSilently();
throw new WebServerException("Unable to start embedded Jetty web server", ex);
}
}
}
use of org.springframework.boot.web.server.WebServerException in project spring-boot by spring-projects.
the class JettyWebServer method start.
@Override
public void start() throws WebServerException {
synchronized (this.monitor) {
if (this.started) {
return;
}
this.server.setConnectors(this.connectors);
if (!this.autoStart) {
return;
}
try {
this.server.start();
for (Handler handler : this.server.getHandlers()) {
handleDeferredInitialize(handler);
}
Connector[] connectors = this.server.getConnectors();
for (Connector connector : connectors) {
try {
connector.start();
} catch (BindException ex) {
if (connector instanceof NetworkConnector) {
throw new PortInUseException(((NetworkConnector) connector).getPort());
}
throw ex;
}
}
this.started = true;
JettyWebServer.logger.info("Jetty started on port(s) " + getActualPortsDescription());
} catch (WebServerException ex) {
throw ex;
} catch (Exception ex) {
throw new WebServerException("Unable to start embedded Jetty server", ex);
}
}
}
use of org.springframework.boot.web.server.WebServerException in project spring-boot by spring-projects.
the class UndertowWebServer method start.
@Override
public void start() throws WebServerException {
synchronized (this.monitor) {
if (this.started) {
return;
}
try {
if (!this.autoStart) {
return;
}
if (this.undertow == null) {
this.undertow = this.builder.build();
}
this.undertow.start();
this.started = true;
UndertowWebServer.logger.info("Undertow started on port(s) " + getPortsDescription());
} catch (Exception ex) {
if (findBindException(ex) != null) {
List<UndertowWebServer.Port> failedPorts = getConfiguredPorts();
List<UndertowWebServer.Port> actualPorts = getActualPorts();
failedPorts.removeAll(actualPorts);
if (failedPorts.size() == 1) {
throw new PortInUseException(failedPorts.iterator().next().getNumber());
}
}
throw new WebServerException("Unable to start embedded Undertow", ex);
}
}
}
use of org.springframework.boot.web.server.WebServerException in project spring-boot by spring-projects.
the class TomcatWebServer method stop.
@Override
public void stop() throws WebServerException {
synchronized (this.monitor) {
boolean wasStarted = this.started;
try {
this.started = false;
try {
stopTomcat();
this.tomcat.destroy();
} catch (LifecycleException ex) {
// swallow and continue
}
} catch (Exception ex) {
throw new WebServerException("Unable to stop embedded Tomcat", ex);
} finally {
if (wasStarted) {
containerCounter.decrementAndGet();
}
}
}
}
use of org.springframework.boot.web.server.WebServerException in project spring-boot by spring-projects.
the class UndertowServletWebServer method start.
@Override
public void start() throws WebServerException {
synchronized (this.monitor) {
if (this.started) {
return;
}
try {
if (!this.autoStart) {
return;
}
if (this.undertow == null) {
this.undertow = createUndertowServer();
}
this.undertow.start();
this.started = true;
UndertowServletWebServer.logger.info("Undertow started on port(s) " + getPortsDescription());
} catch (Exception ex) {
if (findBindException(ex) != null) {
List<Port> failedPorts = getConfiguredPorts();
List<Port> actualPorts = getActualPorts();
failedPorts.removeAll(actualPorts);
if (failedPorts.size() == 1) {
throw new PortInUseException(failedPorts.iterator().next().getNumber());
}
}
throw new WebServerException("Unable to start embedded Undertow", ex);
}
}
}
Aggregations