Hi,

I'm trying to set up websockets using Apache Felix HTTP Jetty 5.0.0 and
Jetty WebSocket 11.0.13.

I register a component that provides a Servlet service, with:
* an empty init() method.
* a service() method that calls init() after configuring the servlet
context for websockets.
Without that delayed configuration,websockets can't be configured.

The configuration is done like this:

    ServletContext servletContext = getServletContext();
    ServletContextHandler contextHandler =
ServletContextHandler.getServletContextHandler(servletContext, "Jetty
WebSocket init");

WebSocketServerComponents.ensureWebSocketComponents(contextHandler.getServer(),
servletContext);
    JettyWebSocketServerContainer.ensureContainer(servletContext);
    super.init();

As a result, I get the following error when connecting the websocket:

    java.lang.ClassCastException: class
org.apache.felix.http.base.internal.whiteboard.PerBundleServletContextImpl
cannot be cast to class
org.eclipse.jetty.server.handler.ContextHandler$Context
        at
org.eclipse.jetty.websocket.core.server.internal.CreatorNegotiator.negotiate(CreatorNegotiator.java:63)
...

Is there a way to mitigate that issue?

Thanks,
Thomas

Reply via email to