users@jersey.java.net

Error using Jersey 1.0.2 with Spring: The ResourceConfig instance does not contain any root resource classes.

From: Jalpesh Patadia <jrp_at_clickbank.com>
Date: Tue, 7 Apr 2009 17:32:17 -0700

Hello everyone,

I have been using Jersey 1.0.2 with the tomcat, and everything had been working great so far. Then I switched over to using the SpringContainer from ServletContainer (replacing the <servlet class> in web.xml)
from :

com.sun.jersey.spi.container.servlet.ServletContainer

 to :

com.sun.jersey.spi.spring.container.servlet.SpringServlet

and I'm getting the following error when I start tomcat. :

Apr 7, 2009 6:14:53 PM 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.WebApplicationImpl.processRootResources(WebApplicationImpl.java:607)
        at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:480)
        at com.sun.jersey.spi.spring.container.servlet.SpringServlet.initiate(SpringServlet.java:80)
        at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:433)
        at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:167)
        at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:197)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1172)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4371)
        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:627)
        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:1149)
        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)


I do not have any beans defined in my spring-applicationContext.xml, since I'm not using anything spring related yet. Here's my web.xml and spring-applicationContext.xml, for posterity.


web.xml

<web-app>
  <display-name>JSR311 Test Web Application</display-name>

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:META-INF/spring-*.xml</param-value>
  </context-param>
  <listener>
    <listener-class>
      org.springframework.web.context.ContextLoaderListener
    </listener-class>
  </listener>
  <servlet>
    <servlet-name>JSR311Handler</servlet-name>
    <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>JSR311Handler</servlet-name>
    <url-pattern>/api/*</url-pattern>
  </servlet-mapping>
</web-app>

spring-applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:seam="http://jboss.com/products/seam/spring-seam" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
                           http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd
                           http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
                           http://jboss.com/products/seam/spring-seam http://jboss.com/products/seam/spring-seam-2.0.xsd
                           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">


</beans>


My HelloWorldResource:


package com.clickbank.api;

import javax.ws.rs.GET;
import javax.ws.rs.Path;

@Path("/test")
public class TestURL
{
    @GET
    public String testMe()
    {
        return "Hello There!";
    }
}


I'd really appreciate if somebody could help me getting this resolved. Once I can get spring working with jersey then I can start using other aspects of my projects with jersey, but this issue has been hampering my progress. I apologize if I'm doing something stupid, as I'm just getting started with jersey.

If you guys want, I can post this in the wiki - but somebody mentioned that I should first try sending to this email first.


Thanks,

Jalpesh


________________________________
PRIVILEGED AND CONFIDENTIAL
This transmission may contain privileged, proprietary or confidential information. If you are not the intended recipient, you are instructed not to review this transmission. If you are not the intended recipient, please notify the sender that you received this message and delete this transmission from your system.