If I use the http-spi functions in a non-shared mode I will end up with two servers listening on two different ports, and the main reason for using the http-spi is sharing
the same port in all my servlets.

If I manage the server myself, It won't be possible to publish the Endpoint as you suggested:

--(snip)--
System.setProperty("com.sun.net.httpserver.HttpServerProvider",
"org.eclipse.jetty.http.spi.JettyHttpServerProvider");

InetSocketAddress addr = new InetSocketAddress("localhost", 8080);
HttpServer server = new JettyHttpServerProvider.createHttpServer(addr, 10);
Endpoint endpoint = Endpoint.publish(endpointURL, myWebServices);
server.start();

--(snip)--

In this code snippet the Endpoint.publish() will instantiate another
server using ServerMgr and won't use the server manually created.

---
Alejandro Alberola
Bio Data Systems
---

El 02/07/14 18:17, Joakim Erdfelt escribió:
That stacktrace is telling you that

com.sun.xml.internal.ws <http://com.sun.xml.internal.ws>.transport.http.server.ServerMgr.createContext(ServerMgr.java:85) is attempting to create a context on a server.

The fact that it attempts to .setExecutor() means that it created a new server at the point of ServerMgr.createContext(). But what is odd is that this attempt to .setExecutor() occurred on an already started server. (which is a no-no, and the cause of the error).

You might want to enable java.util.logging and set the logger named "com.sun.xml.internal.ws <http://com.sun.xml.internal.ws>" to level FINEST and see what its attempting to do.

Some thoughts, because you are using JettyhttpServerProvider.setServer(server), you are essentially wanting to use a shared server instance, regardless of subsequent HttpServer.createHttpServer() calls.
This might be tripping up the WS implementation.

You'll either want to manage the server entirely yourself, or use the http-spi functions in a non-shared mode.

So that simplifies your codebase to the following ....

--(snip)--
System.setProperty("com.sun.net.httpserver.HttpServerProvider",
"org.eclipse.jetty.http.spi.JettyHttpServerProvider");

InetSocketAddress addr = new InetSocketAddress("localhost", 8080);
HttpServer server = new JettyHttpServerProvider.createHttpServer(addr, 10);
Endpoint endpoint = Endpoint.publish(endpointURL, myWebServices);
server.start();

--(snip)--

This is using the http-spi directly, allowing it to manage the http server state and whatnot.
Not the hybrid approach that you were working with.

It seems that the WS implementation you are using requires this approach.


--
Joakim Erdfelt <[email protected] <mailto:[email protected]>>
webtide.com <http://www.webtide.com/> - intalio.com/jetty <http://intalio.com/jetty>
Expert advice, services and support from from the Jetty & CometD experts
eclipse.org/jetty <http://eclipse.org/jetty/> - cometd.org <http://cometd.org/>


On Wed, Jul 2, 2014 at 8:32 AM, Alejandro Alberola <[email protected] <mailto:[email protected]>> wrote:

    The fix works. But, is there a way to hot deploy the WS once the
    Server has been started ?

    If I publish the WS after the Server has been started I get:

    Caused by: java.lang.IllegalStateException: STARTED
        at
    
org.eclipse.jetty.http.spi.DelegatingThreadPool.setExecutor(DelegatingThreadPool.java:55)
        at
    
org.eclipse.jetty.http.spi.JettyHttpServer.setExecutor(JettyHttpServer.java:129)
        at
    
com.sun.xml.internal.ws.transport.http.server.ServerMgr.createContext(ServerMgr.java:85)
        ... 9 more


    Thanks.

    ---
    Alejandro Alberola
    Bio Data Systems
    ---

    El 01/07/14 19:47, Joakim Erdfelt escribió:
    You are hitting this requirement ...

    
https://github.com/eclipse/jetty.project/blob/master/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServer.java#L131

    To fix, change:

    Server server = new Server(8080);

    to

    Server server = new Server(new DelegatingThreadPool()); // <--
    required for http-spi
    ServerConnector connector = new ServerConnector(server);
    connector.setPort(8080);  // <-- your port is now set via a connector
    server.addConnector(connector);

    and try again.

    --
    Joakim Erdfelt <[email protected] <mailto:[email protected]>>
    webtide.com <http://www.webtide.com/> - intalio.com/jetty
    <http://intalio.com/jetty>
    Expert advice, services and support from from the Jetty & CometD
    experts
    eclipse.org/jetty <http://eclipse.org/jetty/> - cometd.org
    <http://cometd.org/>


    On Tue, Jul 1, 2014 at 2:21 AM, Alejandro Alberola
    <[email protected] <mailto:[email protected]>> wrote:

        Hello,

        I have an embedded Jetty 9.2.1 server in my application where
        I have deployed a
        servlet in a ServletContextHandler. At the same time I want
        to deploy a Metro WS
        in the same server using JettyHttpServerProvider, but when I
        try to publish the
        WS Endpoint I get the following exception:

        Caused by: com.sun.xml.internal.ws
        <http://com.sun.xml.internal.ws>.server.ServerRtException:
        Server Runtime Error:
        java.lang.UnsupportedOperationException: !DelegatingThreadPool
            at com.sun.xml.internal.ws
        
<http://com.sun.xml.internal.ws>.transport.http.server.ServerMgr.createContext(ServerMgr.java:102)
            at com.sun.xml.internal.ws
        
<http://com.sun.xml.internal.ws>.transport.http.server.HttpEndpoint.publish(HttpEndpoint.java:63)
            at com.sun.xml.internal.ws
        
<http://com.sun.xml.internal.ws>.transport.http.server.EndpointImpl.publish(EndpointImpl.java:171)
            at
        
com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:118)
            at javax.xml.ws.Endpoint.publish(Endpoint.java:240)

        If I use two Jetty server instances embedded in my
        application and listening in different ports,
        all work properly, but I would like to share the same port
        among the servlet and the Metro WS.

        My faulty code follows:

        -------------------------------------------------
        Server server = new Server(8080);

        System.setProperty("com.sun.net.httpserver.HttpServerProvider",
        "org.eclipse.jetty.http.spi.JettyHttpServerProvider");
        JettyHttpServerProvider.setServer(server);

        ContextHandlerCollection contexts = new
        ContextHandlerCollection();

        servletContext =  new ServletContextHandler(server, "/myapp",
        true, false);
        contexts.addHandler(servletContext);

        ServletHolder servletHolder = new ServletHolder(MyServlet);
        servletContext.addServlet(servletHolder, "/servlet-path");

        HandlerCollection handlerCollection = new HandlerCollection();
        handlerCollection.setHandlers(new Handler[]{ contexts });

        Endpoint endpoint = Endpoint.publish(endpointURL, myWebServices);

        server.setHandler(contexts);

        server.start();
        -------------------------------------------------

        Any idea ?
        Thanks.

        ---
        Alejandro Alberola
        Bio Data Systems
        ---

        _______________________________________________
        jetty-users mailing list
        [email protected] <mailto:[email protected]>
        To change your delivery options, retrieve your password, or
        unsubscribe from this list, visit
        https://dev.eclipse.org/mailman/listinfo/jetty-users




    _______________________________________________
    jetty-users mailing list
    [email protected]  <mailto:[email protected]>
    To change your delivery options, retrieve your password, or unsubscribe 
from this list, visit
    https://dev.eclipse.org/mailman/listinfo/jetty-users


    _______________________________________________
    jetty-users mailing list
    [email protected] <mailto:[email protected]>
    To change your delivery options, retrieve your password, or
    unsubscribe from this list, visit
    https://dev.eclipse.org/mailman/listinfo/jetty-users




_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to