开发者

Exception When Jetty Server Started Remotely- java.net.BindException: Cannot assign requested address: bind

I am fairly new to Jetty and Servlet. Sorry if this sounds really basic. I am using jetty 6.1.22,jetty-util-6.1.22 and Selenium 2.0b2. I am trying to configure the selenium server in the code so that I can avoid the manual process of starting the selenium server on the remote host. The wiki[1] notes say- "In theory, the process is as simple as mapping the "DriverServlet" to a URL, but it's also possible to host the page in a lightweight container, such as Jetty configured entirely in code"

[Edit#1]

Here is what I have so far, basically copy of the code from the RemoteWebDriverServer wiki [1].

If I set the remote host like below, I get bind exception.

public AppServer() throws Exception { 
        try {
            WebAppContext context = new WebAppContext(); 
            context.setContextPath(""); 
            context.setWar("."); 
            server.addHandler(context); 
            context.addServlet(DriverServlet.class, "/wd/*"); 
            SelectChannelConnector connector = new SelectChannelConnector(); 
            connector.setHost("MyRemoteHostIPAddress");
            connector.setPort(4444); 
            server.addConnector(connector); 
            server.start();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 
      } 
      public static void main(String[] args) throws Exception{ 
              new AppServer(); 
      } 
}

Here is the stack trace

2011-06-06 14:39:02.618:INFO::Logging to STDER开发者_开发问答R via org.mortbay.log.StdErrLog
2011-06-06 14:39:02.633:INFO::jetty-6.1.22
2011-06-06 14:39:02.977:WARN::failed SelectChannelConnector@MyRemoteHostIPAddress:4444: java.net.BindException: Cannot assign requested address: bind
2011-06-06 14:39:02.977:WARN::failed Server@b61fd1: java.net.BindException: Cannot assign requested address: bind
Exception in thread "main" java.net.BindException: Cannot assign requested address: bind
at sun.nio.ch.Net.bind(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at org.mortbay.jetty.nio.SelectChannelConnector.open(SelectChannelConnector.java:216)
at org.mortbay.jetty.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:315)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.Server.doStart(Server.java:235)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at AppServer.main(AppServer.java:31)

[Edit#2]

Please disregard my first two comments below. I edited the question.

Is there anything I am missing or doing incorrectly?

Thanks, -Nilesh

[1]http://code.google.com/p/selenium/wiki/RemoteWebDriverServer


I think, the problem is in line:

 connector.setHost("MyRemoteHostIPAddress");

Try to replace "MyRemoteHostIPAddress" with "localhost", or direct IP.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜