Hi there,

>> I think this was introduced by Adam in SIS-30 [1] when we put in
>> Jetty integration in sis-webapp. I think Jetty is just picking the
>> default
>> port to run unit tests on (8080), and that port is in use from time
>> to time.
>> We should probably file a JIRA issue for this as a bug and simply update
>> the config to choose a random, unused port.
>
> If Jetty can easily locate an unused port, that would help.

I've used this in the past for another project. Hopefully it can help
somehow.

    private void bootJetty(int retryCount) {
        String webapp = "./target/app";
        WebAppContext app = // TODO set up this. I'm using guice which
is probably different to SIS usage.
        app.setParentLoaderPriority(true);

        for (int i = 0; i < retryCount; i++) {
            // We explicitly use the SocketConnector because the
SelectChannelConnector locks files
            Connector connector = new SocketConnector();
            connector.setPort(port = 18080 + i);
            connector.setMaxIdleTime(10000);
            server = new Server();
            server.setConnectors(new Connector[]{connector});
            server.setHandler(app);
            try {
                logger.info("Trying to start jetty at port " + port);
                server.start();
                break;
            } catch (Exception ex) {
                server = null;
                logger.error("Cannot start jetty at port " + port + " "
+ ex.getMessage());
            }
        }
    }

Regards,
Peter.

Reply via email to