2014-01-16 94 views
0
static HttpServer server; 
static Datenbank db = new Datenbank(); 

public static void main (String[] args) throws InterruptedException, IOException{ 

    startServer(); 
    db.dbinfo(); 
    Thread.sleep(10*60*1000); 
    System.out.println("Server wurde beendet"); 
} 

public static void startServer() throws IOException, InterruptedException { 

    URI baseUri = UriBuilder.fromUri("http://localhost/").port(4434).build(); 

    ResourceConfig config = new ResourceConfig().register(BetroffenePersonenService.class); 
    HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, config); 

    try{ 
     server.start(); 
     NetworkListener listener = new NetworkListener("grizzly2","localhost", 4434); 
     server.addListener(listener); 
    } 
    catch (Exception e){ 
     System.err.println(e); 

    } 
     } 
    } 

我試圖啓動該服務器,但我不斷收到這個嘗試啓動GrizzlyServer - 未能啓動監聽器 - 已ADRESS使用

16.01.2014 22:04:31 org.lightcouch.CouchDbClientBase process 
INFO: >> HEAD /betroffene HTTP/1.1 
16.01.2014 22:04:31 org.lightcouch.CouchDbClientBase process 
INFO: << Status: 200 
16.01.2014 22:04:31 org.glassfish.jersey.server.ApplicationHandler initialize 
INFO: Initiating Jersey application, version Jersey: 2.5 2013-12-18 14:27:29... 
16.01.2014 22:04:32 org.glassfish.grizzly.http.server.NetworkListener start 
INFO: Started listener bound to [localhost:4434] 
16.01.2014 22:04:32 org.glassfish.grizzly.http.server.HttpServer start 
INFO: [HttpServer] Started. 
16.01.2014 22:04:32 org.glassfish.grizzly.http.server.HttpServer addListener 
SCHWERWIEGEND: Failed to start listener [NetworkListener{name='grizzly2',  host='localhost',  port=4434, secure=false, state=STOPPED}] : java.net.BindException: Address already in use 
16.01.2014 22:04:32 org.glassfish.grizzly.http.server.HttpServer addListener 
SCHWERWIEGEND: java.net.BindException: Address already in use 
java.net.BindException: Address already in use 
at sun.nio.ch.Net.bind(Native Method) 
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:124) 
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59) 
at org.glassfish.grizzly.nio.transport.TCPNIOBindingHandler.bindToChannelAndAddress(TCPNIOBindingHandler.java:132) 
at org.glassfish.grizzly.nio.transport.TCPNIOBindingHandler.bind(TCPNIOBindingHandler.java:88) 
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.bind(TCPNIOTransport.java:233) 
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.bind(TCPNIOTransport.java:213) 
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.bind(TCPNIOTransport.java:204) 
at org.glassfish.grizzly.http.server.NetworkListener.start(NetworkListener.java:680) 
at org.glassfish.grizzly.http.server.HttpServer.addListener(HttpServer.java:171) 
at server.AbleServer.startServer(AbleServer.java:39) 
at server.AbleServer.main(AbleServer.java:23) 

我試圖在網上找到解決方案,但我不能找到任何適合我的工作。 我已經重新啓動了所有內容,但仍然顯示地址正在使用中。 它可能是一個非常小的錯誤,導致所有這一切,但它真的讓我感到沮喪。 您的幫助將不勝感激!

回答

0

服務器實例從

返回
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, config); 

已經已經開始,所以你可以刪除這些行:

server.start(); 
NetworkListener listener = new NetworkListener("grizzly2","localhost", 4434); 
server.addListener(listener); 
+0

我沒有,但我還是告訴我,ADRESS已在使用 – user3203650

+0

確保你殺死了其他服務器進程 – alexey