Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-7775

embedded jetty websocket gets ClassCastException: org.eclipse.jetty.servlet.ServletContextHandler$Context cannot be cast to org.eclipse.jetty.webapp.WebAppContext$Context

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.2.5
    • Fix Version/s: 3.2.7, 3.3.0
    • Component/s: Transports
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      After upgrade from jetty 9.2.5.v20141112 to 9.4.11.v20180605 and cxf from v3.1.5 to v3.2.5, the websocket server code used to work, now getting ClassCastException:

       

      17:08:07.810 [qtp1128117613-31] WARN  org.eclipse.jetty.server.HttpChannel [HttpChannel.java:573] [] - /websocket/

      java.lang.ClassCastException: org.eclipse.jetty.servlet.ServletContextHandler$Context cannot be cast to org.eclipse.jetty.webapp.WebAppContext$Context

              at org.apache.cxf.transport.websocket.jetty9.Jetty9WebSocketDestination.getServer(Jetty9WebSocketDestination.java:125)

              at org.apache.cxf.transport.websocket.jetty9.Jetty9WebSocketDestination.getWebSocketFactory(Jetty9WebSocketDestination.java:132)

              at org.apache.cxf.transport.websocket.jetty9.Jetty9WebSocketDestination.invoke(Jetty9WebSocketDestination.java:102)

              at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)

              at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)

              at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)

              at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:216)

              at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301)

              at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:225)

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)

              at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276)

              at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)

              at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)

              at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)

              at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1317)

              at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)

              at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)

              at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)

              at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1219)

              at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)

              at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)

              at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)

              at org.eclipse.jetty.server.Server.handle(Server.java:531)

              at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:352)

              at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)

              at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)

              at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)

              at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:291)

              at org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:151)

              at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)

              at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)

              at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)

              at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)

              at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)

              at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)

              at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)

              at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:762)

              at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680)

              at java.lang.Thread.run(Thread.java:745)

       

       

      Looks like 

      org.apache.cxf.transport.websocket.jetty9.Jetty9WebSocketDestination was changed to assume ServletContext will always be WebAppContext.Context, we are not using WebAppContext in the program.

       

        Attachments

          Activity

            People

            • Assignee:
              ffang Freeman Yue Fang
              Reporter:
              libinkm Bin
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: