title: Jersey on Jetty on Android throws ContainerException: The ResourceConfig instance does not contain any root resource classes
body: <p>I'm trying to run Jersey on Jetty on Android.</p>
  
  <p>I've created an Android that instantiate a Jetty Server with a Jersey Servlet. Anyway when I start Jetty and visit a REST resource (in my case: <code><a href="http://192.168.1.12:8080/api/hello" rel="nofollow noreferrer">http://192.168.1.12:8080/api/hello</a></code>) I get a ContainerException with message: The ResourceConfig instance does not contain any root resource classes. (see exception stack trace below).</p>
  
  <p>Any idea why?</p>
  
  <p>MORE DETAILS:</p>
  
  <p>Logcat is giving the following SEVER WARNINGS. </p>
  
  <p><code>The following errors and warnings have been detected with resource and/or provider classes:</p>
  
  <p>SEVERE: Missing dependency for field: private java.lang.ThreadLocal com.sun.jersey.server.impl.container.servlet.JSPTemplateProcessor.requestInvoker
  SEVERE: Missing dependency for field: private java.lang.ThreadLocal com.sun.jersey.server.impl.container.servlet.JSPTemplateProcessor.requestInvoker</code></p>
  
  <p>This is strange cause java.lang.ThreadLocal is available for <a href="http://developer.android.com/reference/java/lang/ThreadLocal.html" rel="nofollow noreferrer">Android</a> and HttpServletRequest and HttpServletResponse should be available since I've included servlet-api-2.5.jar in the libs folder.</p>
  
  <p>Jersey is dependent on some javax libraries (jaxb-api-2.2.2.jar,jndi-1.2.1.jar,stax-api-1.0-2.jar) which I had to add to project and set the --core-library parameter temporary to ignore dex warning about javax packages as dependencies.</p>
  
  <p>I also removed the following classes (RenderedImageProvider,DataSourceProvider,MimeMultipartProvider from package com.sun.jersey.core.impl.provider.entity from jersey core jar) to avoid dependencies on java.awt and javax.mail.</p>
  
  <p>EXCEPTION trace:</p>
  
  <pre><code>javax.servlet.UnavailableException: com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
  at org.eclipse.jetty.servlet.ServletHolder.makeUnavailable(ServletHolder.java:409)
  at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:450)
  at org.eclipse.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:331)
  at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
  at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:476)
  at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
  at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:517)
  at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
  at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:935)
  at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:404)
  at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:184)
  at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:870)
  at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
  at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
  at org.eclipse.jetty.server.Server.handle(Server.java:346)
  at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:596)
  at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:1051)
  at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:592)
  at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:214)
  at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:426)
  at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:520)
  at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)
  at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:528)
  at java.lang.Thread.run(Thread.java:1019)
  </code></pre>
  
  <p>Start Server Android Activity:</p>
  
  <pre><code>public class StartServerActivity extends Activity {
  
  private Server webServer;
  
  private final static String LOG_TAG = "Jetty";
  
  
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.main);
  
      System.setProperty("java.net.preferIPv4Stack", "true");
      System.setProperty("java.net.preferIPv6Addresses", "false");
  
      webServer = new Server(8080);
  
      ServletHolder servletHolder = new ServletHolder(com.sun.jersey.spi.container.servlet.ServletContainer.class);
      servletHolder.setInitParameter("com.sun.jersey.config.property.packages", "com.famenu.server.resources");
  
      ServletContextHandler servletContextHandler = new ServletContextHandler(webServer, "/api", true, false);
      servletContextHandler.addServlet(servletHolder, "/hello");
  
      webServer.setHandler(servletContextHandler);
  
  
      try {
          webServer.start();
          Log.d(LOG_TAG, "started Web server");
  
      }
      catch (Exception e) {
          Log.d(LOG_TAG, "unexpected exception starting Web server: " + e);
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Jersey Resource:</p>
  
  <pre><code>package com.famenu.server.resources;
  </code></pre>
  
  <p>import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;</p>
  
  <p>@Path("/")
  public class HelloResource {</p>
  
  <pre><code>@GET
  @Produces("text/plain")
  public String getMsg() {
  
      return "Hello Resource";
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I'm using Jetty 7.3.0.v20110203 , Jersey 1.12 , Android 1.6
  I arrived till this point after another exception explained <a href="https://stackoverflow.com/questions/11191346/jersey-on-jetty-on-android-throws-containerexception-no-webapplication-provide">here</a></p>