The Resourceconfig Instance Does Not Contain Any Root Resource Classes

The ResourceConfig instance does not contain any root resource classes

Basically I corrected it like below and everything worked fine.

<servlet>
<servlet-name >MyWebApplication</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.feature.Redirect</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.JSPTemplatesBasePath</param-name>
<param-value>/views/</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name>
<param-value>/(images|css|jsp)/.*</param-value>
</init-param>
</servlet>

<servlet-mapping>
<servlet-name>MyWebApplication</servlet-name>
<url-pattern>/myapp/*</url-pattern>
</servlet-mapping>

No Idea why : The ResourceConfig instance does not contain any root resource classes

The error:

com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.

means that Jersey can't find service classes. That can be caused by a wrongly named package for the com.sun.jersey.config.property.packages parameter or if the package name is correct but it does not contain resource classes (people sometimes forget to add the @Path annotation on the class).

But I can't find anything wrong with your setup. So this should work!

Check that your application deployed correctly and that your WEB-INF/classes folder actually contains your class with the proper folder path for the package.

Do a full clean and rebuild then try again.

Error: The ResourceConfig instance does not contain any root resource classes

The error got resolved by giving @Produces("text/html") under @Path("/add")
in test.java class.

Also import javax.ws.rs.Produces; so that the @Produce annotation doesn't throw any error...

The ResourceConfig instance does not contain any root resource classes exception in REST API

<param-name>jersey.config.server.provider.packages</param-name>

This param (which tells Jersey which package to scan) is for Jersey 2.x. The 1.x version is

com.sun.jersey.config.property.packages

Additionally:

  • Make your resource class public, move the model into its own class file, and make it public.
  • Your Java code should be in src/main/java so move the restWebservice folder into there

com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes error on Jersey Rest

As said in comments, your configuration is OK. However, apparently you changed the resource package.

Thus the classpath has not been updated. As in comments, a full clean and rebuild will update the classpath (compiled and resources) and worked.

ResourceConfig instance does not contain any root resource classes

@Path("/")
class MyClass{

The class isn't visible to Jersey. Try changing it to (note the addition of "public"):

@Path("/")
public class MyClass{


Related Topics



Leave a reply



Submit