Note that there are some explanatory texts on larger screens.

plurals
  1. POJersey REST The ResourceConfig instance does not contain any root resource classes
    text
    copied!<p>Although this is one ancient question, I still can not find the answer to make this work. Please correct if you find any of my statement is not correct.</p> <p>I have a Java Face app and use REST for the Web Services. I don't think Face has anything to do with my problem at all. The web.xml is:</p> <pre><code>&lt;servlet&gt; &lt;servlet-name&gt;NDREST&lt;/servlet-name&gt; &lt;servlet-class&gt; com.sun.jersey.spi.container.servlet.ServletContainer &lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt; &lt;param-value&gt;com.bi.nd.webservice&lt;/param-value&gt; &lt;/init-param&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;NDREST&lt;/servlet-name&gt; &lt;url-pattern&gt;/nd/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; </code></pre> <p>I have quite a few more servlets in the web.xml since is is a Face app with Trinidad, etc.</p> <p>In the package com.bi.nd.webservice, my resource class is:</p> <pre><code>import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.Marshaller; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @Produces(MediaType.APPLICATION_XML) @Path("/hello") public class TransactionResource { public TransactionResource() { } @GET @Produces(MediaType.TEXT_PLAIN) public String itWorks() { return "Get is OK"; } } </code></pre> <p>The fact that my class has a @GET is enough to identify itself a resource class.<br> Let alone all other complexities, I compiled my source code with Ant in Eclipse and I got this error in the catalina.out file:</p> <pre><code>May 24, 2011 8:48:46 AM com.sun.jersey.api.core.PackagesResourceConfig init INFO: Scanning for root resource and provider classes in the packages: com.bi.nd.webservice May 24, 2011 8:48:46 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate INFO: Initiating Jersey application, version 'Jersey: 1.7 05/20/2011 11:04 AM' May 24, 2011 8:48:46 AM com.sun.jersey.server.impl.application.RootResourceUriRules &lt;init&gt; SEVERE: The ResourceConfig instance does not contain any root resource classes. </code></pre> <p>Some suggested that copy the asm.jar, jsr-api.jar, jersey-server.jar and jersey-core.jar into the app WEB-INF/lib. I did that and it still did not work. I found the suggestion was a bit odd since WEB-INF/lib is a place where Eclipse will install all dependency libraries from the build path. It is not a place where we manually put libraries.</p> <p>Some explained that this error had something to do with Java plug-in and the way Jersey was written. But that was years ago.</p> <p>Can some one explains to me why I keep having this problem?</p> <p>Followup: Although from REST web site, resource class defined as Root resource classes are POJOs (Plain Old Java Objects) that are either annotated with@Path or have at least one method annotated with @Path or a request method designator such as @GET, @PUT, @POST, or @DELETE. Resource methods are methods of a resource class annotated with a request method designator. This section describes how to use Jersey to annotate Java objects to create RESTful web services.</p> <p>I have to add @Path("/hello") to my class, and suddenly Jersey can find my resource class</p> <p>Now the catalina.out file looks like:</p> <pre><code>May 24, 2011 3:13:02 PM com.sun.jersey.api.core.PackagesResourceConfig init INFO: Scanning for root resource and provider classes in the packages: com.bi.nd.webservice May 24, 2011 3:13:02 PM com.sun.jersey.api.core.ScanningResourceConfig logClasses INFO: Root resource classes found: class com.bi.nd.webservice.TransactionResource May 24, 2011 3:13:02 PM com.sun.jersey.api.core.ScanningResourceConfig init INFO: No provider classes found. May 24, 2011 3:13:02 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate INFO: Initiating Jersey application, version 'Jersey: 1.7 05/20/2011 11:04 AM' </code></pre> <p>But the problem is far from over. I try to access the URL <code>http://localhost:8080/nd/hello</code> and I still get the 404 NOT FOUND. Is the Provider class NOT FOUND an important message?</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