users@jersey.java.net

Re: [Jersey] Re: The ResourceConfig instance does not contain any root resource classes.

From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
Date: Wed, 19 Nov 2008 19:32:16 +0100

Hi Davis,

please see bellow...


On Wed, Nov 19, 2008 at 01:04:12PM -0500, Davis Ford wrote:
> I think the problem may be with the servlet-class ?
>
> Some examples on the web, including the official sun jersey blog indicate this:
>
> <servlet-class>com.sun.ws.rest.spi.container.servlet.ServletContainer</servlet-class>

The package was renamed, so the blog is now obsolete.
The updated examples to look at are available at [1].
You can specifically look at [helloworld-webapp] (zip is at [2]),
to see the right configuration.


>
> Below I was using this:
>
> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>

which should be the right one.


>
> When I changed it to the former, I got ClassNotFoundException. This
> perhaps explains why the package scanning doesn't work, since it may
> swallow a CNF if it tries to load

Please try to use the config from the example (update package names accordingly),
then if you still have issues, send a source code of one of your root
resource classes to the list for further help.


> com.sun.ws.rest.api.core.PackagesResourceConfig ? I cannot find any
> of my jars that contain the package name-space com.sun.ws.*
>
> My maven project pulls in the following:
>
> <dependency>
> <groupId>com.sun.jersey</groupId>
> <artifactId>jersey-core</artifactId>
> <version>0.11-ea-SNAPSHOT</version>
> </dependency>
> <dependency>
> <groupId>com.sun.jersey</groupId>
> <artifactId>jersey-server</artifactId>
> <version>0.11-ea-SNAPSHOT</version>
> </dependency>
>
> But neither of these jars contain com.sun.ws.* namespace. It seems I
> am missing a key jar -- does someone have a clue which are missing?

You probably want to use latest snapshot version, which is: 1.0.1-SNAPSHOT.

~Jakub


[1]http://download.java.net/maven/2/com/sun/jersey/samples/jersey-samples/
[2]http://download.java.net/maven/2/com/sun/jersey/samples/helloworld-webapp/1.0.1-SNAPSHOT/helloworld-webapp-1.0.1-SNAPSHOT-project.zip

>
> Regards,
> Davis
>
> On Wed, Nov 19, 2008 at 12:41 PM, Davis Ford <davisford_at_gmail.com> wrote:
> > I know this topic has been discussed on the list extensively. I have
> > tried to read all the posts and suggestions, and none of the proposed
> > solutions seem to work for me.
> >
> > Dev Platform: Windows XP, JDK 6u10, Eclipse 3.3, Maven 2.0.9 using
> > jetty-maven-plugin, tomcat-maven-plugin.
> >
> > If I run either:
> >
> > mvn jetty:run-war
> >
> > or
> >
> > mvn tomcat:run-war
> >
> > I encounter no issues.
> >
> > However, if I run:
> >
> > mvn jetty:run
> >
> > or
> >
> > mvn tomcat:run
> >
> > I keep hitting this:
> >
> > com.sun.jersey.api.container.ContainerException: The ResourceConfig
> > instance does not contain any root resource classes.
> > at com.sun.jersey.impl.application.WebApplicationImpl.processRootResources(WebApplicationImpl.java:765)
> >
> > I tried this (where com.my.package has the Java class that is
> > annotated with @Path)
> >
> > <servlet>
> > <servlet-name>ServletAdaptor</servlet-name>
> > <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
> > <init-param>
> > <param-name>com.sun.ws.rest.config.property.resourceConfigClass</param-name>
> > <param-value>com.sun.ws.rest.api.core.PackagesResourceConfig</param-value>
> > </init-param>
> > <init-param>
> > <param-name>com.sun.ws.rest.config.property.packages</param-name>
> > <param-value>com.my.package</param-value>
> > </init-param>
> >
> > Alternatively I tried this:
> >
> > package com.my.package;
> > public class MyResourceConfig extends DefaultResourceConfig {
> > public MyResourceConfig() {
> > super(com.my.package.MyServlet.class);
> > }
> > }
> >
> > and then modified web.xml as such ->
> >
> > <servlet>
> > <servlet-name>ServletAdaptor</servlet-name>
> > <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
> > <init-param>
> > <param-name>com.sun.ws.rest.config.property.resourceConfigClass</param-name>
> > <param-value>com.sun.ws.rest.api.core.PackagesResourceConfig</param-value>
> > </init-param>
> > <init-param>
> > <param-name>com.sun.ws.rest.config.property.packages</param-name>
> > <param-value>com.my.package.MyResourceConfig</param-value>
> > </init-param>
> >
> > I still hit the same exception. Any ideas what I might be missing?
> >
> > Thanks in advance!
> >
> > Regards,
> > Davis
> >
>
>
>
> --
> Zeno Consulting, Inc.
> http://www.zenoconsulting.biz
> 248.894.4922 phone
> 313.884.2977 fax
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>