Caused by: java.net.BindException: Cannot assign requested address: bind

abo2427 2017-07-28 04:49:25
本地测试正常发布,可是换到公网ip的时候,运行报错

import javax.jws.WebService;
import javax.xml.ws.Endpoint;

@WebService
public class WebTest {

public String transWords(String words) {
String res = "=========";
System.out.println("调用了服务");
return res+"==="+words;
}

public static void main(String[] args) {
Endpoint.publish("http://14.127.254.10:9002/Service/web",new WebTest());
System.out.println("发布了====");
}
}

================================================================================================================================================================================================

Exception in thread "main" com.sun.xml.internal.ws.server.ServerRtException: 服务器运行时错误: java.net.BindException: Cannot assign requested address: bind
at com.sun.xml.internal.ws.transport.http.server.ServerMgr.createContext(ServerMgr.java:117)
at com.sun.xml.internal.ws.transport.http.server.HttpEndpoint.publish(HttpEndpoint.java:64)
at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:232)
at com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:126)
at javax.xml.ws.Endpoint.publish(Endpoint.java:240)
at com.airx.server.cxf.WebTest.main(WebTest.java:16)
Caused by: java.net.BindException: Cannot assign requested address: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at sun.net.httpserver.ServerImpl.<init>(ServerImpl.java:100)
at sun.net.httpserver.HttpServerImpl.<init>(HttpServerImpl.java:50)
at sun.net.httpserver.DefaultHttpServerProvider.createHttpServer(DefaultHttpServerProvider.java:35)
at com.sun.net.httpserver.HttpServer.create(HttpServer.java:130)
at com.sun.xml.internal.ws.transport.http.server.ServerMgr.createContext(ServerMgr.java:86)
... 5 more
...全文
1158 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yuanhong5212 2019-02-18
  • 打赏
  • 举报
回复
你确认这个地址是自己的吗 要本地地址才行 192.168这种 10.0什么的
  • 打赏
  • 举报
回复 1
改下端口号,今天碰到这个问题,改下端口号就解决了,貌似是端口被占用了
abo2427 2017-07-28
  • 打赏
  • 举报
回复

本地ip__localhost测试正常,换成这个ip就不行了,求解___

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧