title: Exception starting filter WebSocket filter netbeans 7.3 glassfish 4
body: <p>i am trying to implement simple video transfer between two html pages using java websocket api.
  The webcam server captures the webcam and sends to server endpoint which broadcasts to every connected clients.
  The webcam server code</p>
  
  <pre><code>&lt;video autoplay id="vid" style="display: none;"&gt;&lt;/video&gt;
      &lt;canvas id="canvas" width="640" height="480" style="border: 1px solid #d3d3d3;"&gt;&lt;/canvas&gt;
      &lt;div id="data1"&gt;&lt;/div&gt;
      &lt;script&gt;
             var video = document.querySelector("#vid");
             var canvas = document.querySelector('#canvas');
             var ctx = canvas.getContext('2d');
             var localMediaStream = null;
             var ws = new WebSocket("ws://127.0.0.1:8080/WebApplication5/endpointwcv");
             ws.onopen = function () {
                  console.log("Openened connection to websocket");
              };
              ws.onerror = function (evt) {
                  writeToScreen('&lt;span style="color: red;"&gt;ERROR:&lt;/span&gt; ' + evt.data);
              };
             var onCameraFail = function (e) {
                  console.log('Camera did not work.', e);
              };
              timer = setInterval(function () {
                                ctx.drawImage(video, 0, 0, 640, 480);
                                var data = canvas.toDataURL('image/jpeg', 1.0);
                                ws.send(data);
                                }, 255);
  
             navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
             window.URL = window.URL || window.webkitURL;
             navigator.getUserMedia({ video: true }, function (stream) {
                  video.src = window.URL.createObjectURL(stream);
  
  }, onCameraFail);
  </code></pre>
  
  <p>The code for server endpoint
      /*
   Imports here
  */</p>
  
  <pre><code>@ServerEndpoint("/endpointwcv")
  public class NewWSEndpoint {
  private static Set&lt;Session&gt; peers = Collections.synchronizedSet(new HashSet&lt;Session&gt;());
  
  @OnMessage
  public String onMessage( Session session,byte[] data) {
  try {
          System.out.println(data);
      for(Session s:peers){
  
                      s.getBasicRemote().sendObject(data);
              }
  } catch (IOException | EncodeException e) {
      System.out.println("Error in facedetection, ignoring message:" + e.getMessage());
  }
      return null;
  }
  
  public String onMessage( Session session,String data) {
  try {
          System.out.println(data);
      for(Session s:peers){
  
                      s.getBasicRemote().sendText(data);
              }
  } catch (IOException e) {
      System.out.println("Error in facedetection, ignoring message:" + e.getMessage());
  }
      return null;
  }
  
  @OnOpen
  public void onOpen(Session session) throws IOException {
      peers.add(session);
      session.getBasicRemote().sendText("hiiiiiii");
  }
  
  @OnClose
  public void onClose() {
  
      System.out.println("Closed");
  }
  
  @OnError
  public void onError(Session s, Throwable t) {
      System.out.println("error");
  }    
  }
  </code></pre>
  
  <p>And there is a recieving client who accesses the webcam</p>
  
  <pre><code>&lt;div id="d1"&gt;&lt;/div&gt;
      &lt;canvas id="target" width="640" height="480" style="border: 1px solid #d3d3d3;"&gt;&lt;/canvas&gt;
      &lt;script&gt;
          var ws = new WebSocket("ws://127.0.0.1:8080/WebApplication5/endpointwcv");
          var myURL = window.URL || window.webkitURL;
          ws.onopen = function () {
                console.log("Openened connection to websocket");
          };
  
          ws.onmessage=function (msg) {
                  var target = document.getElementById("target");
                  url=myURL.createObjectURL(msg);
                  target.src = url;
          };
      &lt;/script&gt;
  </code></pre>
  
  <p>On Running the project on GlassFish 4.0 with java ee 7 api, nothing happens. Plz help me out.On the console there's a warning</p>
  
  <pre><code>WARNING:   Class 'javax.ejb.PostActivate' not found, interception based on it is not     enabled
  WARNING:   Class 'javax.ejb.PrePassivate' not found, interception based on it is not     enabled
  </code></pre>
  
  <p>.....</p>
  
  <pre><code>Exception starting filter WebSocket filter
  java.lang.InstantiationException
  at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:135)
  at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:5297)
  ...
  </code></pre>
  
  <p><a href="https://docs.google.com/file/d/0B3sGeNMMcaSDZ0xQNzJUYlRYQzA/edit?usp=sharing" rel="nofollow">This is the link to download the project</a></p>