I have a working application that’s been using jetty-server version 9.4.15.v20190215. Due to a vulnerability scan that found issues in jetty-server dependencies, I looked into upgrading my app to use jetty-server 9.4.19-v20190610, the latest release as I’m writing this.

    I tried to compile the application again, and I’m getting this error during startup:

    1. Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/util/ssl/SslContextFactory$Client
    2. at org.eclipse.jetty.websocket.client.HttpClientProvider.get(HttpClientProvider.java:49)
    3. at org.eclipse.jetty.websocket.client.WebSocketClient.<init>(WebSocketClient.java:261)
    4. at org.eclipse.jetty.websocket.jsr356.ClientContainer.<init>(ClientContainer.java:140)
    5. at org.eclipse.jetty.websocket.jsr356.server.ServerContainer.<init>(ServerContainer.java:94)
    6. at org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer.configureContext(WebSocketServerContainerInitializer.java:152)
    7. at it.kahoot.merlin.jetty.JettyServer.main(JettyServer.java:53)
    8. Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.util.ssl.SslContextFactory$Client
    9. at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    10. at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    11. at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    12. at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    13. ... 6 more

    I understand the class org.eclipse.jetty.util.ssl.SslContextFactory$Client is not found anymore.
    How do I proceed?

    By tracing back the jetty-server versions to the first one that causes this issue, I found that it’s jetty-server version 9.4.16.v20190411, whose release notes mention the following:

    1. jetty-9.4.16.v20190411 - 11 April 2019
    2. ...
    3. + 3464 Split SslContextFactory into Client and Server
    4. ...

    Given the class name, I figured I needed to add jetty-util to my dependencies (pom.xml), so I did:

    1. <!-- pom.xml -->
    2. ...
    3. <properties>
    4. <jetty-version>9.4.19.v20190610</jetty-version>
    5. </properties>
    6. <dependency>
    7. <groupId>org.eclipse.jetty</groupId>
    8. <artifactId>jetty-server</artifactId>
    9. <version>${jetty-version}</version>
    10. </dependency>
    11. <!-- Needed for the SSLContextFactory$Client class -->
    12. <dependency>
    13. <groupId>org.eclipse.jetty</groupId>
    14. <artifactId>jetty-util</artifactId>
    15. <version>${jetty-version}</version>
    16. </dependency>

    Compilation and startup now work again with the newest Jetty.