How to discover embedded Jetty port after requesting random available port?

The function getPort() returns the configured value.

Try server.getConnectors()[0].getLocalPort() it should return the selected port.

For Jetty 9:

You need to use ((ServerConnector)server.getConnectors()[0]).getLocalPort().

In both cases: you need to call server.start() first.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)