我必须通过 ant 任务执行已编译的 Java 服务器以进行分配,以便我可以为其构建客户端。我没有服务器的代码,但它应该在启动后在 localhost 的 8181 端口上运行。它可以在 Windows 和其他 linux 机器上运行,但我无法在这台机器上运行(crunchbang)。这是我得到的错误:
BUILD SUCCESSFUL
Total time: 1 second
root@drne:/home/wallen/uni/workspace/A5# ant run-server
Buildfile: /home/wallen/uni/workspace/A5/build.xml
setseed:
run-server:
[java] Exception in thread "main" com.sun.xml.internal.ws.server.ServerRtException: Server Runtime Error: java.net.BindException: Cannot assign requested address
[java] at com.sun.xml.internal.ws.transport.http.server.ServerMgr.createContext(ServerMgr.java:102)
[java] at com.sun.xml.internal.ws.transport.http.server.HttpEndpoint.publish(HttpEndpoint.java:63)
[java] at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:171)
[java] at com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:113)
[java] at javax.xml.ws.Endpoint.publish(Endpoint.java:240)
[java] at it.polito.dp2.PJS.lab5.PJSInfoServer.main(Unknown Source)
[java] Caused by: java.net.BindException: Cannot assign requested address
[java] at sun.nio.ch.Net.bind0(Native Method)
[java] at sun.nio.ch.Net.bind(Net.java:344)
[java] at sun.nio.ch.Net.bind(Net.java:336)
[java] at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:199)
[java] at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
[java] at sun.net.httpserver.ServerImpl.<init>(ServerImpl.java:98)
[java] at sun.net.httpserver.HttpServerImpl.<init>(HttpServerImpl.java:50)
[java] at sun.net.httpserver.DefaultHttpServerProvider.createHttpServer(DefaultHttpServerProvider.java:35)
[java] at com.sun.net.httpserver.HttpServer.create(HttpServer.java:129)
[java] at com.sun.xml.internal.ws.transport.http.server.ServerMgr.createContext(ServerMgr.java:84)
[java] ... 5 more
[java] Java Result: 1
我尝试过的事情:
- 检查是否有另一台服务器在该端口上运行
- 以 su 运行它