users@jersey.java.net

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

From: Davis Ford <davisford_at_gmail.com>
Date: Wed, 19 Nov 2008 13:04:12 -0500

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>

Below I was using this:

<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>

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
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?

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