title: WebSocket 404 error
body: <p>I'm trying to implement WebSocket on my site. Following basic tutorials I added this class:</p>
  
  <pre><code>@ServerEndpoint(value="/websocketendpoint")
  public class WebSocket {
      private static Set&lt;Session&gt; peers = Collections.synchronizedSet(new HashSet&lt;Session&gt;());
  
      @OnMessage
      public String onMessage(String message){ return null; }
  
      @OnOpen
      public void onOpen(Session peer){ peers.add(peer); }
  
      @OnClose
      public void onClose(Session peer){ peers.remove(peer); }
  }
  </code></pre>
  
  <p>And this JS:</p>
  
  <pre><code>var wsUri = "ws://" + document.location.host + document.location.pathname + "websocketendpoint";
  var ws = new WebSocket(wsUri);
  ws.onopen = function(){
      ws.send("Message to send");
      alert("Message is sent...");
  };
  ws.onmessage = function (evt){   
      var received_msg = evt.data;
      alert("Message is received...");
  };
  ws.onclose = function(){ 
      alert("Connection is closed...");
  };
  </code></pre>
  
  <p>I added the js to one of my pages, and only <code>ws.onclose</code> is called, in console I get this error:</p>
  
  <blockquote>
    <p><code>Firefox</code>: Firefox can't establish a connection to the server at
    ws://localhost:8080/Mysite/websocketendpoint</p>
    
    <p><code>Chrome</code>: Error during WebSocket handshake: Unexpected response code:
    404</p>
  </blockquote>
  
  <p>I tried using 'ws://echo.websocket.org' as <code>wsUri</code> and it works, so I guess the problem is on server side.</p>
  
  <p>I'm using the following libraries: <em>javaee-api-7.0, javax.websocket-api-1.0</em>
  My browsers are compatible with websockets (I checked)</p>
  
  <p>Similar topics didn't help me, so I'm asking you for sugestions on how to fix the problem</p>