我对Jetty和Servlet相当陌生。抱歉,如果这听起来很基本。我使用的是jetty 6.1.22、jetty-util-6.1.22和Selenium2.0b2。我试图在代码中配置selenium服务器,以避免在远程主机上启动selenium服务器的手动过程。wiki1注释说--“理论上,这个过程就像将"DriverServlet”映射到一个DriverServlet一样简单,但也可以将页面托管在轻量级容器中,比如完全用代码配置的Jetty。“
Edit#1
以下是到目前为止,我从RemoteWebDriverServer wiki 1中复制的代码。
如果像下面这样设置远程主机,就会得到绑定异常。
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();
}
}这是堆栈跟踪
2011-06-06 14:39:02.618:INFO::Logging to STDERR 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
请不要理会我下面的前两条评论。我编辑了这个问题.
我错过了什么或者做错了什么吗?
谢谢,-Nilesh
1个http://code.google.com/p/selenium/wiki/RemoteWebDriverServer
发布于 2012-04-05 08:41:50
我认为,问题是:
connector.setHost("MyRemoteHostIPAddress");尝试将"MyRemoteHostIPAddress"替换为"localhost"或直接IP。
https://stackoverflow.com/questions/6231316
复制相似问题