I have to execute a compiled Java server through an ant task for an assignment so that I can build a client for it.
I don’t have the code of the server but it’s supposed to run on the 8181 port of the localhost after being launched. It’s working in windows and on other linux machines but I cannot run on this one (crunchbang).
This is the error I get:
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
Things I’ve tried:
- checking if there is another server running on that port
- running it as su
I managed to fix what was giving me this error and as I supposed at the beginning of the matter it was not related to any java code: my loopback interface was weirdly down.
ifconfig lo updid the trick.