users@jersey.java.net

[Jersey] Re: Problems with deployment in Tomcat 7

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Thu, 26 Jan 2012 16:39:06 +0100

can you try deploy and access helloworld-webapp sample?

http://search.maven.org/#artifactdetails%7Ccom.sun.jersey.samples%7Chelloworld-webapp%7C1.11%7Cwar

I was playing with Tomcat recently and everything worked as expected,
even the servlet 3 deployment without web.xml..

Pavel

On 1/14/12 4:39 AM, david_at_traveltripper.com wrote:
> 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.
>