Discussion:
Problems with deployment in Tomcat 7
d***@public.gmane.org
2012-01-14 03:39:00 UTC
Permalink
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.
Pavel Bucek
2012-01-26 15:39:06 UTC
Permalink
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
Post by d***@public.gmane.org
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.
<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>
@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
"
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.
Loading...