title: GCM: java.lang.NoClassDefFoundError: com/google/android/gcm/server/Sender
body: <p>I have been trying to get Google Cloud Messaging to work in eclipse.  I was able to compile the example given on their demo webpage and run that without any errors; however, when I try to create my own example using jersey I get the run time error "java.lang.NoClassDefFoundError: com/google/android/gcm/server/Sender" when the following code tries to create a sender.</p>
  
  <pre><code>@POST
  @Path("/send")
  public Response sendMessage() throws IOException
  {
      Sender sender = new Sender("api_key");
      Message message = new Message.Builder().build();
      sender.send(message, DataStore.getDevices(), 5);
      return Response.status(200).entity("Success").build();
  }
  </code></pre>
  
  <p>Note: I have replaced my real api key with api_key.  I know it works because I was able to get the demo working by running the ant commands explained in the tutorial.  Also just to be specific in case of ambiguity, the error I am getting is server side, and has nothing to do with the android device.</p>
  
  <p>Things I have already tried:</p>
  
  <ol>
  <li>I have included the gcm-server.jar in my WEB-INF/lib folder and under project properties I have included it in the build path.</li>
  <li>I have also tried, as mentioned on other sites, to include json_simple-1.1.jar the same way I included gcm-server.jar.  I don't see how this would effect this error but I saw this listed as an answer in a few different places.</li>
  <li><strong>(Solution)</strong> Deleted the tomcat server and created a new one. I probably could have just cleaned the project instead and had the same results.</li>
  </ol>
  
  <p>Demo tutorial link: <a href="http://developer.android.com/guide/google/gcm/demo.html" rel="nofollow">http://developer.android.com/guide/google/gcm/demo.html</a>.</p>