title: How to get JSR-356 (javax.websockets.api) working on Jetty 9.3 JEE environment not embedded?
body: <p>I am having a hard time trying to get a simple echo server using javax.websockets on jetty 9.3 servlets (not embedded).</p>
  
  <p>Server: </p>
  
  <pre><code>import java.io.IOException;
  
  import javax.websocket.Endpoint;
  import javax.websocket.EndpointConfig;
  import javax.websocket.MessageHandler;
  import javax.websocket.RemoteEndpoint;
  import javax.websocket.Session;
  
  
  public class EchoServer extends Endpoint {
  
      @Override
      public void onOpen( Session session, EndpointConfig EndPointCfg ) {
          RemoteEndpoint.Basic remoteEndpointBasic = session.getBasicRemote();
          session.addMessageHandler( new EchoMessageHandler( remoteEndpointBasic ) );
  
      }
  
      private static class EchoMessageHandler implements MessageHandler.Whole&lt;String&gt; {
  
          private final RemoteEndpoint.Basic remoteEndpointBasic;
  
  
          private EchoMessageHandler( RemoteEndpoint.Basic remoteEndpointBasic ) {
              this.remoteEndpointBasic = remoteEndpointBasic;
          }
  
  
          @Override
          public void onMessage( String message ) {
              try {
                  if ( remoteEndpointBasic != null ) {
                      remoteEndpointBasic.sendText( message );
                  }
              } catch ( IOException e ) {
                  e.printStackTrace();
              }
          }
      }
  }
  </code></pre>
  
  <p>Configuration class:</p>
  
  <pre><code>import java.util.HashSet;
  import java.util.Set;
  
  import javax.websocket.Endpoint;
  import javax.websocket.server.ServerApplicationConfig;
  import javax.websocket.server.ServerEndpointConfig;
  
  
  public class EchoServerCfg implements ServerApplicationConfig {
  
      @Override
      public Set&lt;Class&lt;?&gt;&gt; getAnnotatedEndpointClasses( Set&lt;Class&lt;?&gt;&gt; set ) {
          // TODO Auto-generated method stub
          return null;
      }
  
  
      @Override
      public Set&lt;ServerEndpointConfig&gt; getEndpointConfigs( Set&lt;Class&lt;? extends Endpoint&gt;&gt; set ) {
          Set&lt;ServerEndpointConfig&gt; result = new HashSet&lt;ServerEndpointConfig&gt;();
          if ( set.contains( EchoServer.class ) ) {
              result.add( ServerEndpointConfig.Builder.create( EchoServer.class, "/websocket/echo" ).build() );
          }
          return result;
      }
  
  }
  </code></pre>
  
  <p>It works just fine on tomcat 7.0, but no luck on Jetty 9.3, any help will be appreciated. </p>
  
  <hr>
  
  <p><strong>Edit 1:</strong>
  It's missing the information about the problem, I am getting 404 so I believe the endpoint does not get mapped:</p>
  
  <pre><code>$ wscat -c localhost:8080/websocket/echo 
  
  error: Error: unexpected server response (404)
  </code></pre>
  
  <p>but it works fine on tomcat: </p>
  
  <pre><code>wscat -c localhost:8081/websocket/echo 
  
  connected (press CTRL+C to quit)
  &gt; test
  
  &lt; test
  </code></pre>
  
  <hr>
  
  <p><strong>Edit 2:</strong></p>
  
  <p>Java version:</p>
  
  <pre><code>tiago@lenovo:~$ /opt/jdk/bin/java -version
  java version "1.8.0_20"
  Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
  Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
  </code></pre>
  
  <p>I am using <a href="http://eclipse-jetty.github.io/" rel="nofollow">eclipse-jetty plugin</a> to run, but here's my command in the shell: </p>
  
  <pre><code>tiago@lenovo:~$ ps axo cmd  | grep jetty  | sed -re 's/:|\s+/\n/g'
  /opt/jdk/bin/java
  -Djetty.launcher.configuration=/tmp/eclipseJettyPlugin.config.TestServlet.xml
  -Dfile.encoding=UTF-8
  -classpath
  /opt/eclipse/configuration/org.eclipse.osgi/bundles/1011/1/.cp/lib/eclipse-jetty-starters-common.jar
  /opt/eclipse/configuration/org.eclipse.osgi/bundles/1011/1/.cp/lib/eclipse-jetty-starters-util.jar
  /opt/eclipse/configuration/org.eclipse.osgi/bundles/1011/1/.cp/lib/eclipse-jetty-starters-console.jar
  /opt/eclipse/configuration/org.eclipse.osgi/bundles/1011/1/.cp/lib/eclipse-jetty-starters-jetty9.jar
  /opt/jetty/lib/jetty-rewrite-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-servlets-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-jndi-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-xml-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-annotations-9.3.3.v20150827.jar
  /opt/jetty/lib/annotations/asm-commons-5.0.1.jar
  /opt/jetty/lib/annotations/javax.annotation-api-1.2.jar
  /opt/jetty/lib/annotations/asm-5.0.1.jar
  /opt/jetty/lib/jetty-plus-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-proxy-9.3.3.v20150827.jar
  /opt/jetty/lib/servlet-api-3.1.jar
  /opt/jetty/lib/jetty-server-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-infinispan-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-schemas-3.1.jar
  /opt/jetty/lib/jetty-servlet-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-io-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-http-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-jmx-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-quickstart-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-deploy-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-jaas-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-client-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-security-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-util-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-nosql-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-alpn-server-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-continuation-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-webapp-9.3.3.v20150827.jar
  /opt/jetty/lib/jetty-jaspi-9.3.3.v20150827.jar
  net.sourceforge.eclipsejetty.starter.jetty9.Jetty9LauncherMain
  </code></pre>
  
  <hr>
  
  <p><strong>Edit 3: [SOLVED]</strong></p>
  
  <p>The problem was jetty-eclipse plugin, it turns out that their version 3.9.0 released yesterday 2015/10/11 solves the problem. Also deploying manually does the tricky but it's nice to use the plugin when using eclipse.</p>