ResourceConfig Instance Does Not Contain Root Resource Classes

What is wrong here?

The ResourceConfig instance does not contain any root resource classes. Dec 10, 2010 10:21:24 AM com.sun.jersey.spi.spring.container.servlet.SpringServlet initiate SEVERE: Exception occurred when intialization com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes. at com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:103) at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1182) at com.sun.jersey.server.impl.application.WebApplicationImpl.access$600(WebApplicationImpl.java:161) at com.sun.jersey.server.impl.application.WebApplicationImpl$12.f(WebApplicationImpl.java:698) at com.sun.jersey.server.impl.application.WebApplicationImpl$12.f(WebApplicationImpl.java:695) at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:197) at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:695) at com.sun.jersey.spi.spring.container.servlet.SpringServlet.initiate(SpringServlet.java:117) 

Filter:

 <filter> <filter-name>JerseyFilter</filter-name> <filter-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</filter-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> </filter> <filter-mapping> <filter-name>JerseyFilter</filter-name> <url-pattern>/myresource/*</url-pattern> </filter-mapping> 

the code:

 @Path ("/admin") public class AdminUiResource { @GET @Produces ("text/html") @Path ("/singup") public Viewable getSignUp () { return new Viewable("/public/signup", "Test"); } } 
+72
jersey
Dec 10 2018-10-10
source share
22 answers

I basically fixed it as shown below and everything is working 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> 
+7
Dec 11 2018-10-12T00:
source share

Have you tried adding

 <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>my.package.name</param-value> </init-param> 

in the definition of SpringServlet? Obviously, replace my.package.name with the package that AdminUiResource is in, and make sure it is in the classpath.

+74
Dec 10 '10 at
source share

I am new to jersey. I had the same problem. But when I removed "/" and just used @path ("admin"), it worked.

 @Path("admin") public class AdminUiResource { ... } 
+28
Jan 25 '13 at 7:08
source share

This means that he could not find any class that could be executed as a RESTful Jersey web service.

Check:

  • Is ' com.sun.jersey.config.property.packages ' missing in your web.xml.
  • Value for com.sun.jersey.config.property.packages The parameter is missing or not valid (the specified package does not exist). This should be the package in which you put your POJO classes that work as jersey services.
  • Is there at least one POJO class that has a method annotated with the @Path attribute.
+26
May 13 '12 at 16:25
source share

YOU NEED TO ADD YOUR PACKAGE NAME TO

 <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>your.package.name</param-value> </init-param> 

ALSO ONE HEALTH THAT I KNOW
I need to update my project after MAVEN BUILD , otherwise it will show me the same error.
Please comment. If you know the reason why we need to update the project?

+26
Oct 31 '14 at 6:15
source share

Your resource package must contain at least one pojo that is either annotated with @Path or has at least one method annotated with @Path or a query method pointer such as @GET, @PUT, @POST or @DELETE. Resource methods are methods of a resource class annotated with a query method pointer. This solved my problem.

+12
Feb 01 '12 at 9:00
source share

I get this exception due to the lack of ResourseConfig in Web.xml.

Add

 <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>/* Name of Package where your service class exists */</param-value> </init-param> 

A service class means: a class that contains services such as: @Path("/orders")

+8
Feb 22 '13 at 6:04 on
source share

I ran into this problem with JBOSS EAP 6.1. I managed to deploy my code via eclipse to a JBOSS server, but as soon as I tried to deploy the file as a WAR file in JBOSS, I started getting this error.

The solution was to configure web.xml to work properly with JBOSS, allowing the two to work together.

The following two lines were commented on in web.xml to allow JBOSS to execute their own configurations.

 <!-- <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>com.your.package</param-value> </init-param> --> 

Then add the following context options after

 <context-param> <param-name>resteasy.scan</param-name> <param-value>false</param-value> </context-param> <context-param> <param-name>resteasy.scan.resources</param-name> <param-value>false</param-value> </context-param> <context-param> <param-name>resteasy.scan.providers</param-name> <param-value>false</param-value> </context-param> 
+8
Feb 17 '14 at 20:25
source share

I had the same problem trying to start webapp from an eclipse project. Once I copied the .class files to /WEB-INF/classes , it worked fine.

+7
Mar 30 2018-12-18T00:
source share

I had the same problem, tested many different examples and tried all possible solutions. What finally worked for me, when I added @Path("") over the class line, I left it.

+5
Sep 21
source share

Had the same problem and found out that it was a problem with the way I deployed my source code. As the error message says: "...does not contain any root resource classes" . Therefore, he could not find the resource classes in the configured package. I just used the classes incorrectly - why didn't he take it.

I forgot to deploy my class files to the / WEB -INF / classes WAR directory - at first I just got it right in the root of the WAR file. Therefore, when he looked for resource classes, he did not find them because they existed in another (wrong) place.

+3
Jan 30 '12 at 20:20
source share

The same problem - web.xml looks like this:

 <servlet> <servlet-name>JerseyServlet</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <init-param> <param-name>javax.ws.rs.Application</param-name> <param-value>com.mystuff.web.JerseyApplication</param-value> </init-param> ... 

Providing a custom application overrides any automatic class definition using XML. You need to implement the correct methods for writing your own code for connecting classes. See Javadocs.

+3
Feb 11 '13 at 18:15
source share

Another possible reason for this error is that you forgot to add libraries that are already in the /WEBINF/lib folder to the build path (for example, when importing a .war file and not checking libraries when prompted by the wizard). It just happened to me.

+3
May 13 '13 at 8:31
source share

This happened to me when I deployed my main.jar without checking to add entries to the directory in the export jar menu in Eclipse .

+3
Sep 12 '13 at 9:01
source share

Ok, a little late to answer. I ran into the same problem and google searches were in vain. However, I managed to find what the problem was. There can be many reasons for getting this error, but I got an error due to the following, and I wanted to share this with my fellow developers.

  • I previously used Jersey 1.3 and I was getting this error. But when I upgraded the cans to the latest version of Jersey, this problem was resolved.
  • Another instance in which I received this error was when I tried to deploy my service to JBoss by creating a war file. I made a mistake including Java files in .war instead of java classes.
+2
Jul 02 '11 at 2:50
source share

I had to add a trailing slash to the end of @path

 @Path ("/admin/") 
+2
Apr 04 '13 at 14:26
source share

Ok ... for me, only servlet class assignment com.sum.jersey.spi.container.servlet.ServletContainer works fine, I use IDE (Eclipse Mars)

 <servlet> <servlet-name>Jersey Web Application</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Jersey Web Application</servlet-name> <url-pattern>/frontend/*</url-pattern> </servlet-mapping> 

but for some reason I had to restart my computer to work on my localhost. If still not working? You should add this code between your "servlet" tags in your web.xml.

 <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>the.package.name</param-value> </init-param> 

"the.package.name" is the name of the package in which you have classes. If you are using an IDE, upgrade the project and run Tomcat again. still not working? restart your computer and you will work.

+2
Aug 05 '15 at 17:22
source share

Another thing to check is a combination of previous entries

In the web.xml file you can:

 <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>com.acme.rest</param-value> </init-param> 

and you can have

 <context-param> <param-name>resteasy.scan</param-name> <param-value>false</param-value> </context-param> <context-param> <param-name>resteasy.scan.providers</param-name> <param-value>false</param-value> </context-param> <context-param> <param-name>resteasy.scan.resources</param-name> <param-value>false</param-value> </context-param> 

but you cannot have both, or you get such an error. The fix in this case would be to comment on one or the other (perhaps the first code fragment will be commented out)

+2
Jan 26 '16 at 15:27
source share

yes adding an init parameter to com.sun.jersey.config.property.packages fixed this problem for me.

combined the knitwear services into a maven based spring application and got this error.

+1
Jan 28 '14 at 11:51
source share

I also got this error, please take care of the configurations in xml.

I wrote com.sun.jersey.comfig.property.packages

Instead of com.sun.jersey.config.property.packages

After correction, it works.

+1
Jul 19 '14 at 17:53
source share

this problem is due to the fact that knitwear cannot find the dependecy package for your holiday an announced service

check the distribution of the project package and approve what is equal to your web.xml parameter value

+1
Mar 03 '15 at 12:18
source share

In my case, I added jars twice to the assembly path after importing from the war. He did a great job after removing additional cans that displayed error descriptor error pages.

adding

 <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>service.package.name</param-value> </init-param> 
0
Oct 27 '16 at 8:23
source share



All Articles