users@jersey.java.net

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

From: Farrukh Najmi <farrukh_at_wellfleetsoftware.com>
Date: Sun, 14 Dec 2008 19:29:14 -0500

Hi Guys,

I would be grateful for some idea on how to get past this issue as I
have a release that is held up until this REST interface is working. Thanks.

Here is what relevant parts of my web.xml look like:

  <servlet>
    <servlet-name>Registry REST Interface</servlet-name>
    
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>org.freebxml.omar.server.interfaces.rest</param-value>
    </init-param>
    <load-on-startup>4</load-on-startup>
  </servlet>
  <servlet-mapping>
     <servlet-name>Registry REST Interface</servlet-name>
     <url-pattern>/search/*</url-pattern>
  </servlet-mapping>
 
Here is what my Resource class looks like. Its modeled after the
SpringAutowiredResource sample:

package org.freebxml.omar.server.interfaces.rest;

@Path("/search")
@Component
@Scope("singleton")
public class RegistryRestSearchResource {

    @Context
    UriInfo uriInfo;
    @Context
    Request request;
    @Context
    HttpServletResponse servletResponse;
    @Autowired
    private RegistryFacade registryFacade = null;

    @GET
    @Produces("application/xml")
    public Response search() {
        ....
        return Response.status(200).entity(resp).build();//"OK"

    }
}

Thanks.

Farrukh Najmi wrote:
>
> OK I found that the jersey-spring module has moved under contrib:
>
> http://download.java.net/maven/2/com/sun/jersey/contribs/jersey-spring/1.0.1/
>
>
> So my latest jersey deps are:
>
> <dependency>
> <groupId>com.sun.jersey</groupId>
> <artifactId>jersey-server</artifactId>
> <version>1.0.1</version>
> </dependency>
> <dependency>
> <groupId>com.sun.jersey.contribs</groupId>
> <artifactId>jersey-spring</artifactId>
> <version>1.0.1</version>
> </dependency>
>
> With that change I am now getting the following error:
>
> com.sun.jersey.api.container.ContainerException: The ResourceConfig
> instance does not contain any root resource classes.
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl.processRootResources(WebApplicationImpl.java:613)
>
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:492)
>
> at
> com.sun.jersey.spi.spring.container.servlet.SpringServlet.initiate(SpringServlet.java:80)
>
> at
> com.sun.jersey.spi.container.servlet.ServletContainer.load(ServletContainer.java:540)
>
> at
> com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:207)
>
> at
> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
>
> at
> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
> at
> org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
>
> at
> org.apache.catalina.core.StandardContext.start(StandardContext.java:4364)
> at
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
>
> at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
> at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
> at
> org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
>
> at
> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:511)
> at
> org.apache.catalina.startup.HostConfig.check(HostConfig.java:1229)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
>
> at
> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
>
> at
> com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
> at
> org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1465)
>
> at
> org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:821)
>
> at
> org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:349)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>
> at
> org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:196)
>
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
>
> at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
>
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
>
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
>
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
>
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
>
> at
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
> at java.lang.Thread.run(Thread.java:619)
>
> Searching archives I see:
>
> <http://www.nabble.com/HELP---ResourceConfig-does-not-contain-any-root-resource-classes-td16856708.html>
>
>
> But I cannot fathom what I am doing that I should fix. Please help.
> Thanks.
>
> Farrukh Najmi wrote:
>>
>> Hello,
>>
>> I am updating my jersey based rest interface to latest bits. I find
>> the pom for jersey-server-1.0.1.jar but not for jersey-spring-1.0.1.jar.
>> Is there a wiki page that maintains jar compatibility for jersey
>> jars? Thanks for any tips.
>>
>> I tried using jersey-server-1.0.1.jar and jersey-spring-1.0.jar and I
>> am getting the following exception during servlet startup:
>>
>> java.lang.ClassNotFoundException:
>> com.sun.jersey.spi.service.ComponentProvider
>> at
>> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
>>
>> at
>> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
>>
>> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
>> at java.lang.Class.getDeclaredConstructors0(Native Method)
>> at
>> java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
>> at java.lang.Class.getConstructor0(Class.java:2699)
>> at java.lang.Class.newInstance0(Class.java:326)
>> at java.lang.Class.newInstance(Class.java:308)
>> at
>> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1104)
>>
>> at
>> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
>> at
>> org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
>>
>> at
>> org.apache.catalina.core.StandardContext.start(StandardContext.java:4364)
>>
>> at
>> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
>>
>> at
>> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
>> at
>> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
>> at
>> org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
>>
>> at
>> org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
>>
>> at
>> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
>> at
>> org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
>> at
>> org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
>>
>> at
>> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
>>
>> at
>> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
>> at
>> org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
>> at
>> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
>> at
>> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
>> at
>> org.apache.catalina.core.StandardService.start(StandardService.java:516)
>> at
>> org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
>> at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>
>> at java.lang.reflect.Method.invoke(Method.java:597)
>> at
>> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
>> at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
>>
>> Here is what I have in the servlet configuration in web.xml:
>>
>> <servlet>
>> <servlet-name>Registry REST Interface</servlet-name>
>>
>> <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
>>
>> <init-param>
>> <param-name>com.sun.jersey.config.property.packages</param-name>
>>
>> <param-value>org.freebxml.omar.server.interfaces.rest</param-value>
>> </init-param>
>> <load-on-startup>4</load-on-startup>
>> </servlet>
>> <servlet-mapping>
>> <servlet-name>Registry REST Interface</servlet-name>
>> <url-pattern>/search/*</url-pattern>
>> </servlet-mapping>
>>
>> What am I doing wrong? Thanks for your help.
>>
>
>


-- 
Regards,
Farrukh Najmi
Web: http://www.wellfleetsoftware.com