0
votes

I am fairly new to Jersey and REST, so I am following learning path at http://jersey.java.net/nonav/documentation/latest/getting-started.html

When I try to run the main class in example, I am getting following exception:

Exception in thread "main" com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes. at com.sun.jersey.server.impl.application.RootResourceUriRules.(RootResourceUriRules.java:99) at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1298) at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:169) at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:775) at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:771) at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193) at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:771) at com.sun.jersey.api.container.ContainerFactory.createContainer(ContainerFactory.java:172) at com.sun.jersey.api.container.ContainerFactory.createContainer(ContainerFactory.java:134) at com.sun.jersey.api.container.grizzly2.GrizzlyServerFactory.createHttpServer(GrizzlyServerFactory.java:242) at com.vb.test.Main.startServer(Main.java:26) at com.vb.test.Main.main(Main.java:30)

The line 26 in my Main class, which is also available in link is :

return GrizzlyServerFactory.createHttpServer(BASE_URI, rc);
1

1 Answers

1
votes

the reason for this exception should be on previous line (25)

ResourceConfig rc = new PackagesResourceConfig("com.sun.jersey.samples.helloworld.resources");

"com.sun.jersey.samples.helloworld.resources" is package where are your resources. Is it correct?

Or, you can use ClassNamesResourceConfig:

RecourceConfig rc = new ClassNamesResourceConfig(HelloWorldResource.class.getName());

See related javadoc for more details:
http://jersey.java.net/nonav/apidocs/1.11/jersey/com/sun/jersey/api/core/PackagesResourceConfig.html
http://jersey.java.net/nonav/apidocs/1.11/jersey/com/sun/jersey/api/core/ClassNamesResourceConfig.html