Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] Jetty server - java.net.BindException: Address already in use (on MAC OS X)

some versions of windows are 'special'...it doesn't complain about two processing trying to open the same port, it just silently lets one wait for the other to end and then it takes over

you just didn't see that in this case because both connectors were in the same program...

try running your fix twice at the same time on windows and then kill one, then do same on mac (or any OS other then windows) and you'll see the bind exception

cheers,
jesse


--
jesse mcconnell
jesse.mcconnell@xxxxxxxxx


On Wed, May 1, 2013 at 8:35 AM, George Goglidze <george@xxxxxxxxxxxx> wrote:
Perfect!!! 

Thanks a lot guys… this has fixed the issue :) 

I'm just surprised it was working on Windows though… Any ideas why? 

Thanks, 

On 1 May 2013, at 14:27, Joakim Erdfelt <joakim@xxxxxxxxxxx> wrote:

You have 2 connectors, both at the same port.

    Server  server = new Server(port);  // creates connector #1
  SelectChannelConnector connector = new SelectChannelConnector();
  connector.setPort(port);
  server.addConnector(connector); // adds connector #2.

Change the first line to

    Server  server = new Server();  // no port specified


--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Developer advice, services and support
from the Jetty & CometD experts


On Wed, May 1, 2013 at 5:42 AM, George Goglidze <george@xxxxxxxxxxxx> wrote:
Hi all,

This is my first post in this mailing list. and I am sorry if I have chosen a wrong one. 
Please if so, direct me to the correct mailing list and I'll post there.

I have written a java application, which is using embedded jetty server.
It runs just fine on Windows system, but does not run on MAC OS X 10.8.3 (mountain lion).

It gives me the following exception:
891  [main] WARN  org.eclipse.jetty.util.component.AbstractLifeCycle  - FAILED SelectChannelConnector@0.0.0.0:8080: java.net.BindException: Address already in use

I have the following code:

Server server = new Server(port);
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);
connector.setThreadPool(new QueuedThreadPool(200));
server.addConnector(connector);

ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");

// ERROR 404
context.addServlet(new ServletHolder(new HttpDefaultHandler()),"/*");


// IMAGES
context.addServlet(new ServletHolder(new ImageServlet()), "/img/*");

// OTHER STATIC CONTENT
context.addServlet(new ServletHolder(new OtherServlet()), "/other/*");


// WEB COMPONENT
context.addServlet(new ServletHolder(new webConfigMainMenuHandler(0,0)), web_rootFolder + "");
context.addServlet(new ServletHolder(new webConfigMainMenuHandler(0,0)), web_rootFolder + "/main.html");

context.setErrorHandler(createErrorHandler());

        server.setHandler(context);

        server.start();


The exception is given on the last line: server.start()

I have already tried to run this using "sudo". So it's not permissions problem. 

Many thanks for your help,

George,

_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-dev


_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-dev


_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-dev



Back to the top