This report details a critical runtime exception encountered for derivatives trading (USDS Futures) within a Play Framework 3 / Pekko environment.
When initializing the WebSocket client within a CompletableFuture (e.g., on Play's default ForkJoinPool), the ServiceLoader mechanism fails to find Jetty WebSocket extension implementations.
- Error:
java.util.NoSuchElementException originating from java.util.ServiceLoader and traced up through org.eclipse.jetty.websocket.api.ExtensionConfig.getParser.
- Cause: The
ServiceLoader relies on the Thread.currentThread().getContextClassLoader(). When the initialization code runs on a worker thread from a thread pool (like ForkJoinPool), this context classloader may not have visibility of the full application dependency classpath where the Jetty service implementations reside.
- Trigger: Instantiating
new DerivativesTradingUsdsFuturesWebSocketStreams(wsConnectionPool) inside a CompletableFuture.supplyAsync() block.
This report details a critical runtime exception encountered for derivatives trading (USDS Futures) within a Play Framework 3 / Pekko environment.
When initializing the WebSocket client within a
CompletableFuture(e.g., on Play's defaultForkJoinPool), theServiceLoadermechanism fails to find Jetty WebSocket extension implementations.java.util.NoSuchElementExceptionoriginating fromjava.util.ServiceLoaderand traced up throughorg.eclipse.jetty.websocket.api.ExtensionConfig.getParser.ServiceLoaderrelies on theThread.currentThread().getContextClassLoader(). When the initialization code runs on a worker thread from a thread pool (likeForkJoinPool), this context classloader may not have visibility of the full application dependency classpath where the Jetty service implementations reside.new DerivativesTradingUsdsFuturesWebSocketStreams(wsConnectionPool)inside aCompletableFuture.supplyAsync()block.