Jetty HTTP server ip and port binding error: ServiceConstructionException

Jetty HTTP server ip and port binding error: ServiceConstructionException

[eclipse-jetty] 无法在端口 9,091 上启动 Jetty 服务器:无法分配请求的地址

我正在使用 jetty HTTP 服务器发布 REST Web 服务。

配置: 服务器IP:20.121.21.22 端口:8081

对于上面的配置,它抛出以下异常。

org.apache.cxf.service.factory.ServiceConstructionException

Caused by: org.apache.cxf.interceptor.Fault: Could not start Jetty server on port 8,081: Cannot assign requested address at org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine.addServant(JettyHTTPServerEngine.java:386) at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.activate(JettyHTTPDestination.java:178) at org.apache.cxf.transport.AbstractObservable.setMessageObserver(AbstractObservable.java:48) at org.apache.cxf.binding.AbstractBaseBindingFactory.addListener(AbstractBaseBindingFactory.java:95) at org.apache.cxf.endpoint.ServerImpl.start(ServerImpl.java:131) at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:192) ... 3 more Caused by: java.net.BindException: Cannot assign requested address 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.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:209) at org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:289) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55) at org.eclipse.jetty.server.Server.doStart(Server.java:253) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55) at org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine.addServant(JettyHTTPServerEngine.java:375) ... 8 more

错误消息中显示的端口是 8,081,但我配置的是 8081。

有人可以帮忙吗?

只有当指定的 IP 不是自己的接口时才会发生这种情况。 套接字无法绑定到该 IP, 实际上错误是正确的,但是错误消息是错误的,因为它在消息中显示了错误的端口。