Currently we have a Jetty 7 server started this way
//create a new server listening on the 80
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setReuseAddress(false);
connector.setPort(80);
server.setConnectors(new Connector[]{connector});
...
server.start();
setReuseAddress
C:\Users\bacadmin>netstat -anov | find ":80 "
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 3976
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 3808
TCP [::]:80 [::]:0 LISTENING 3976
Jetty throws exception if the port is already in use. Are you catching all exceptions and suppressing it somewhere?
Regarding reserving a port: This is not really possible. If you keep running your jetty application all the time and use 80, then that kind of reserved it for you...
(added code to help in identifying the root cause)
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
public class Main {
public static void main(String[] args) {
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setReuseAddress(false);
connector.setPort(80);
server.setConnectors(new Connector[]{connector});
try {
server.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
In my environment, this definitely get java.net.BindException: Address already in use: bind