2011-04-25 26 views
3

嘗試在Eclipse中運行我的第一個Java Web服務教程時出現這些錯誤。這是什麼意思:(一個簡單的Java webservice出現錯誤

SayHello Web Service started. 
Exception in thread "main" com.sun.xml.internal.ws.server.ServerRtException: Server Runtime Error: java.net.BindException: Address already in use: bind 
    at com.sun.xml.internal.ws.transport.http.server.ServerMgr.createContext(Unknown Source) 
    at com.sun.xml.internal.ws.transport.http.server.HttpEndpoint.publish(Unknown Source) 
    at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(Unknown Source) 
    at com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(Unknown Source) 
    at javax.xml.ws.Endpoint.publish(Unknown Source) 
    at com.myfirst.wsServer.RunService.main(RunService.java:14) 
Caused by: java.net.BindException: Address already in use: 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 sun.net.httpserver.ServerImpl.<init>(Unknown Source) 
    at sun.net.httpserver.HttpServerImpl.<init>(Unknown Source) 
    at sun.net.httpserver.DefaultHttpServerProvider.createHttpServer(Unknown Source) 
    at com.sun.net.httpserver.HttpServer.create(Unknown Source) 
    ... 6 more 

回答

5

這意味着你已經綁定到端口號的過程。停止正在聽這些端口的過程,你會好到哪裏去。它可能是服務器你已經開始了,你應該能夠在Eclipse上看到它的輸出爲一個控制檯,如果你看到了,請點擊紅色的大方塊來停止它,如果你在Eclipse之外啓動服務器,使用netstat | grep 'port number'找到它,然後關閉它

2

這意味着你正在嘗試啓動容器偵聽已被另一個實例佔用的端口,你可以試着運行netstat來找出進程ID(PID)並將其終止。

0

它只是表示您的地址(通常是端口號xxxx)已被其他應用程序使用。嘗試更改終端發佈者的端口號。

public static void main(String[] args) { 
    Endpoint.publish("http://localhost:1234/ws/hello", new WallStreetImpl()); 
} 

來源:Java.Net.BindException: Address Already In Use: Bind