List of usage examples for org.springframework.boot.web.server PortInUseException PortInUseException
public PortInUseException(int port)
From source file:org.springframework.boot.web.embedded.jetty.JettyWebServer.java
@Override public void start() throws WebServerException { synchronized (this.monitor) { if (this.started) { return; }/*from w w w.j av a 2s . c o m*/ 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() + " with context path '" + getContextPath() + "'"); } catch (WebServerException ex) { stopSilently(); throw ex; } catch (Exception ex) { stopSilently(); throw new WebServerException("Unable to start embedded Jetty server", ex); } } }
From source file:org.springframework.boot.web.embedded.netty.NettyWebServer.java
@Override public void start() throws WebServerException { if (this.disposableServer == null) { try {//from w w w .j a v a2 s .c o m this.disposableServer = startHttpServer(); } catch (Exception ex) { ChannelBindException bindException = findBindException(ex); if (bindException != null) { throw new PortInUseException(bindException.localPort()); } throw new WebServerException("Unable to start Netty", ex); } NettyWebServer.logger.info("Netty started on port(s): " + getPort()); startDaemonAwaitThread(this.disposableServer); } }
From source file:org.springframework.boot.web.embedded.undertow.UndertowServletWebServer.java
@Override public void start() throws WebServerException { synchronized (this.monitor) { if (this.started) { return; }// www . j a v a2 s . co m 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() + " with context path '" + this.contextPath + "'"); } catch (Exception ex) { try { 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); } finally { stopSilently(); } } } }
From source file:org.springframework.boot.web.embedded.undertow.UndertowWebServer.java
@Override public void start() throws WebServerException { synchronized (this.monitor) { if (this.started) { return; }/*ww w .j av a 2 s .c o m*/ 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) { try { 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); } finally { stopSilently(); } } } }