Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Firstly, note that having @GET on a class is not enough to identify it as a root resource class; the class must have an @Path on it. Yours does, so that's not the problem.</p> <p>I was having the same problem as you: it worked in Eclipse, but then didn't work when I built it for external use.</p> <p>I'm using embedded Jetty, with a main() that looks like this:</p> <pre><code>public static void main(String argv[]) { try { // from http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty Server server = new Server(8080); ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); contextHandler.setContextPath("/"); server.setHandler(contextHandler); // http://stackoverflow.com/questions/9670363/how-do-i-programmatically-configure-jersey-to-use-jackson-for-json-deserializa final PackagesResourceConfig prc = new PackagesResourceConfig("com.ultimatefoodfight.server.api"); final Map&lt;String, Object&gt; prcProperties = prc.getProperties(); prcProperties.put(JSONConfiguration.FEATURE_POJO_MAPPING, true); // from http://stackoverflow.com/questions/7421574/embedded-jetty-with-jersey-or-resteasy contextHandler.addServlet(new ServletHolder(new ServletContainer(prc)), "/*"); server.start(); server.join(); } catch(Exception e) { System.out.println(e); } } </code></pre> <p>(When embedding Jetty, this takes the place of a web.xml.) com.sun.jersey.api.core.PackagesResourceConfig scans the named classes for root resource provider classes -- I'm sure the web.xml is just pointing at the same. This worked fine in Eclipse. Server startup correctly reports this in the console:</p> <pre><code>INFO: Scanning for root resource and provider classes in the packages: com.ultimatefoodfight.server.api Jul 29, 2012 7:31:28 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses INFO: Root resource classes found: class com.ultimatefoodfight.server.api.Users class com.ultimatefoodfight.server.api.Contests </code></pre> <p>However, when I start the application on a server, I only get the first two lines of that, and no Root resource classes are found.</p> <p>It turns out that when you make a jar, there are different options for how it is constructed; in particular, if you just make it by listing the paths to the classes, you get just those entries. But if you point jar at the directory with a wild card, you also get all the intermediate paths. See this message for the example that tipped me off: <a href="https://groups.google.com/d/msg/neo4j/0dNqGXvEbNg/xaNlRiU1cHMJ">https://groups.google.com/d/msg/neo4j/0dNqGXvEbNg/xaNlRiU1cHMJ</a> .</p> <p>The PackagesResourceConfig class depends on having a directory with the name of the package in order to find the classes within it. I went back to Eclipse, and found an option at the bottom of the "Export ... > Jar" dialog for "Add directory entries." I turned that on, exported the jar again, and then the scanning found my resource classes. You'll need to find some comparable option in your build environment.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload