users@jersey.java.net

[Jersey] Problems with deployment in Tomcat 7

From: <david_at_traveltripper.com>
Date: Sat, 14 Jan 2012 03:39:00 +0000 (GMT)

Hi,

I have been using the documentation to attempt to deploy a basic
application in Tomcat 7. I have used each of the Servlet 3.0 types of
configurations, (one without any web.xml, and two with a web.xml) and a
Servlet 2.x deployment descriptor based config. None of them work.

The closest thing to anything working was the following:

  <servlet>
    <servlet-name>IntegrationTestFacade</servlet-name>
   
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</s
ervlet-class>
    <init-param>
      <param-name>com.sun.jersey.config.property.packages</param-name>
     
<param-value>com.traveltripper.stargazer.intg.rt.ws.resource</param-val
ue>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
  <servlet-name>IntegrationTestFacade</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>
 

My @ApplicationPath is "rttestfacade". I have a helloworld resource
annotated as follows:

@Path("/helloworld")
public class ARIResource {

    @GET
    @Produces("text/html")
    public String helloworld() {
        return "<html><head></head><body>HELLO WORLD!</body></html>";
    }
}

I point my browser to
http://myhost/<context-path>/rttestfacade/helloworld, and get a 404 not
found exception. I did add some tracing to the getClass method in my
class that implements Application. I see the following in my eclipse
tomcat server console:

"
Jan 13, 2012 6:30:12 PM
com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.11 12/09/2011
11:05 AM'
Jan 13, 2012 6:30:12 PM
com.sun.jersey.server.impl.application.DeferredResourceConfig$Applicati
onHolder <init>
INFO: Instantiated the Application class
com.traveltripper.stargazer.intg.rt.svc.IntegrationTestApplication
Just added a resource to the test application: class
com.traveltripper.stargazer.intg.rt.ws.resource.ARIResource
Just added a resource to the test application: class
com.traveltripper.stargazer.intg.rt.ws.resource.ARIResource
Just added a resource to the test application: class
com.traveltripper.stargazer.intg.rt.ws.resource.ARIResource
Just added a resource to the test application: class
com.traveltripper.stargazer.intg.rt.ws.resource.ARIResource
"

The 'just added a resource ...' is my little tracing. Why this method
gets called four times is a mystery. However, in my browser I get a 404
resource not found error. With the other configurations I get the same
404 error, but I also don't see any indication that Jersey is
initializing my resource provider.

Is there a comprehensive cook-book for Tomcat 7 deployments? That would
be really useful.

Any help is greatly appreciated.