0

I am simply following the example here: javax.websocket client simple example

My maven repository looks like:

<!-- https://mvnrepository.com/artifact/javax/javaee-api -->
<dependency>
  <groupId>javax</groupId>
  <artifactId>javaee-api</artifactId>
  <version>7.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.tyrus/tyrus-container-jdk-client -->
<dependency>
  <groupId>org.glassfish.tyrus</groupId>
  <artifactId>tyrus-container-jdk-client</artifactId>
  <version>1.13</version>
</dependency>

But I cannot understand the error message:

javax.websocket.DeploymentException
    at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:388)
    at pre.Web.<init>(Web.java:19)
    at pre.TestApp.main(TestApp.java:10)
Caused by: java.lang.NullPointerException
    at org.glassfish.tyrus.core.AnnotatedEndpoint.<init>(AnnotatedEndpoint.java:161)
    at org.glassfish.tyrus.core.AnnotatedEndpoint.fromInstance(AnnotatedEndpoint.java:135)
    at org.glassfish.tyrus.client.ClientManager$3.run(ClientManager.java:564)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.glassfish.tyrus.client.ClientManager$SameThreadExecutorService.execute(ClientManager.java:871)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
    at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:516)
    at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:378)
    ... 2 more
Exception in thread "main" java.lang.NullPointerException
    at pre.Web.sendMessage(Web.java:49)
    at pre.TestApp.main(TestApp.java:20)

What is the problem?

Community
  • 1
  • 1
Flair
  • 2,609
  • 1
  • 29
  • 41
  • from the stacktrace it seems like you might not have @ClientEndpoint annotation on your client endpoint. Also, you don't need the javaee-api dependency, it will be transitively downloaded from tyrus. – Pavel Bucek Aug 05 '16 at 18:47
  • I figured out that annotation problem, but now the code seems stuck at this one line: `container.connectToServer(this, endpointURI);`. I am not sure why this line is an infinite loop (or whatever) in the code. And I am going to use javaee-api dependency to use the json library later. – Flair Aug 06 '16 at 17:46

0 Answers0