Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8146086

Publishing two webservices on same port fails with "java.net.BindException: Address already in use"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 9
    • None
    • xml
    • b103
    • generic
    • Verified

        Problem reported and fix provided by Kubota Yuji:

        Publishing two services:


        Endpoint endPoint1 = Endpoint.publish("http://0.0.0.0:8081/method1",
                                                                        new Method1());
        Endpoint endPoint2 = Endpoint.publish("http://0.0.0.0:8081/method2",
                                                                         new Method2());
         
        ends with exception:
        Exception in thread "main"
        com.sun.xml.internal.ws.server.ServerRtException: Server Runtime
        Error: java.net.BindException: Address already in use
                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 wstest.WSTest.main(WSTest.java:27)
        Caused by: java.net.BindException: Address already in use
                at sun.nio.ch.Net.bind0(Native Method)
                at sun.nio.ch.Net.bind(Net.java:432)
                at sun.nio.ch.Net.bind(Net.java:424)
                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:102)
                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

        see http://mail.openjdk.java.net/pipermail/core-libs-dev/2015-December/037067.html for more details.

              mkos Miroslav Kos (Inactive)
              mkos Miroslav Kos (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: