[NETCONF-953] Unable to load org.eclipse.jetty.websocket.server.WebSocketServerFactory Created: 08/Feb/23  Updated: 26/Feb/23  Resolved: 26/Feb/23

Status: Resolved
Project: netconf
Component/s: restconf-nb
Affects Version/s: None
Fix Version/s: 4.0.6, 5.0.3

Type: Bug Priority: Highest
Reporter: Ivan Hrasko Assignee: Ruslan Kashapov
Resolution: Done Votes: 0
Labels: pt, regression
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File Streaming RFC 8040.postman_collection.json     File karaf.log    
Issue Links:
Blocks
blocks NETCONF-970 Websocket timeout exception Resolved
blocks NETCONF-483 Netconf Notification event-Time will... Resolved

 Description   
  1. Run Karaf and install odl-netconf-topology and odl-restconf-nb features
  2. Change use SSE setting to use-sse=false in restconf-nb-(5.0.2-SNAPSHOT)-config.cfg
  3. Run Postman collection requests #1 and #2 to create data change event subscription.
  4. In Linux command line run: wscat --header "Authorization: Basic YWRtaW46YWRtaW4=" -c ws://localhost:8181/rests/data-change-event-subscription/network-topology:network-topology/datastore=CONFIGURATION/scope=SUBTREE

You will get response 500, see attached karaf.log.

 



 Comments   
Comment by Robert Varga [ 09/Feb/23 ]

 

Hmm:

Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.websocket.server.WebSocketServerFactory cannot be found by org.opendaylight.netconf.restconf-nb_5.0.2.SNAPSHOT
    at org.eclipse.osgi.internal.loader.BundleLoader.generateException(BundleLoader.java:541) ~[?:?]
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:536) ~[?:?]
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:416) ~[?:?]
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:168) ~[?:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
    at java.lang.Class.forName0(Native Method) ~[?:?]
    at java.lang.Class.forName(Class.java:467) ~[?:?]
    at org.eclipse.jetty.websocket.servlet.WebSocketServletFactory$Loader.load(WebSocketServletFactory.java:48) ~[bundleFile:9.4.50.v20221201]
    ... 36 more

in the context of:

java.lang.RuntimeException: Unable to load org.eclipse.jetty.websocket.server.WebSocketServerFactory
    at org.eclipse.jetty.websocket.servlet.WebSocketServletFactory$Loader.load(WebSocketServletFactory.java:54) ~[bundleFile:9.4.50.v20221201]
    at org.eclipse.jetty.websocket.servlet.WebSocketServlet.init(WebSocketServlet.java:140) ~[bundleFile:9.4.50.v20221201]
    at javax.servlet.GenericServlet.init(GenericServlet.java:180) ~[bundleFile:4.0.4]
    at org.ops4j.pax.web.service.spi.servlet.OsgiInitializedServlet.init(OsgiInitializedServlet.java:68) ~[bundleFile:?]
    at org.eclipse.jetty.servlet.ServletHolder$Wrapper.init(ServletHolder.java:1345) ~[bundleFile:9.4.50.v20221201]

feels like a Jetty-side issue in OSGi context: Class.forName() is run-of-the mill instantiation. If jetty.websocket.server wants to be found by that call, it should be attaching as a fragment to jetty.websocket.server.

 

On the other hand, restconf-nb is the context bundle and hence it should be doing one of:

  • Import-Package org.eclipse.jetty.websocket.server.WebSocketServerFactory
  • Dynamic-Import-Package org.eclipse.jetty.websocket.server.WebSocketServerFactory

Since this is static wiring, we should be okay with former, as it should be immediately satisfied.

Still on the first hand , RESTCONF as such should not care about Jetty (or Undertow, or whatever), really, but I do not remember how well that works in practice.

Comment by Ruslan Kashapov [ 15/Feb/23 ]

issue is caused by unsatisfied dependency on jetty's websocket-server bundle,
it was expected to be dynamically imported (via websocket-servlet manifest).
Explicit definition of restconf-nb bundle dependency on websocket-servlet fixes the case.

Generated at Wed Feb 07 20:16:19 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.