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
How to Call a Method with a Separate Thread in Java
Adding Up Bigdecimals Using Streams
Differencebetween Class.This and This in Java
A Regex to Match a Substring That Isn't Followed by a Certain Other Substring
How to Get the File Name from a String Containing the Absolute File Path
How to Disable Jsessionid in Tomcat Servlet
How to Combine Two Hashmap Objects Containing the Same Types
Easy Way of Running the Same Junit Test Over and Over
Try-Catch-Finally-Return Clarification
Why Java.Util.Optional Is Not Serializable, How to Serialize the Object with Such Fields
How to Properly Express Jpql "Join Fetch" with "Where" Clause as JPA 2 Criteriaquery
How to Read Numeric Strings in Excel Cells as String (Not Numbers)
Java.Util.Stream with Resultset
How to Solve Circular Reference in JSON Serializer Caused by Hibernate Bidirectional Mapping
How to Get Names of Classes Inside a Jar File
Error: Servlet Jar Not Loaded... Offending Class: Javax/Servlet/Servlet.Class