Testing java code sample

Hello, i'm new in this comunitty and working on WebSockets but i've got some experience working on java, so i wanted totest the java sample code to develop my own app, but when i run the code i get the following error:

Exception in thread "main" java.lang.RuntimeException: Could not find an implementation class.
at javax.websocket.ContainerProvider.getWebSocketContainer(ContainerProvider.java:73)
at main.WSClient.main(WSClient.java:25)

what am i doing wrong?

thank you


  • Hi there,

    I'm using a ClientManager myself (since that allows me to set a ReconnectHandler). Quick example:

    package com.example;
    import org.glassfish.tyrus.client.ClientManager;
    import javax.websocket.ClientEndpoint;
    import javax.websocket.OnMessage;
    import javax.websocket.Session;
    import java.net.URI;
    public class WebSocketClient {
       public void onMessage(final String message) {
          System.out.println("ticks update: " + message);
       public static void main(final String[] args) throws Exception {
          ClientManager clientManager = ClientManager.createClient();
          // clientManager.getProperties().put(ClientProperties.RECONNECT_HANDLER, new ReconnectHandler());
          WebSocketClient webSocketClient = new WebSocketClient();
          Session session = clientManager.connectToServer(webSocketClient, URI.create("wss://ws.binaryws.com/websockets/v3"));

    I'm using Tyrus as websocket client/server, so the pom-file will look like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  • The similar problem here. I try to use your code snippet but there is another error message "App id is mandatory to access our api. Please register your application."
    I make an API Token and added it to the request
    Session session = clientManager.connectToServer(webSocketClient, URI.create("wss://ws.binaryws.com/websockets/v3?app_id=2ay9VE55........"));
    But still not work. Need some help to esatblished a stable web connection with java.
    Thank you

Sign In or Register to comment.