users@jersey.java.net

Re: [Jersey] Re: Having problems getting Jersey up and running

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 16 Jan 2009 15:02:21 +0100

Hi Allan,

What are you using in your WEB-INF/lib ? what are the jars files. This
error indicates that Tomcat cannot find the servlet
"com.sun.jersey.spi.spring.container.servlet.SpringServlet" because
you do not have the correct jars. Please read the dependencies
document for what you require:

https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.1/jersey/dependencies.html

I am assuming you copied the web.xml from the spring-annotations sample:

   http://download.java.net/maven/2/com/sun/jersey/samples/spring-annotations/1.0.1/spring-annotations-1.0.1-project.zip

If you build this sample you can find all the dependent jars in the
location:

   target/spring-annotations/WEB-INF/lib

Paul.

On Jan 16, 2009, at 1:01 AM, Allan Ditzel wrote:

> Sorry for the bump, but here's more that I've tried, just to give
> more context:
>
> I just tried just loading the spring servlet and letting spring
> instantiate the resource:
>
> <servlet>
> <servlet-name>Jersey Spring Web Application</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>Jersey Spring Web Application</servlet-name>
> <url-pattern>/rest/*</url-pattern>
> </servlet-mapping>
>
> Spring config:
>
> <bean id="dynamicImageService" class="com.company.web.rest.DynamicImageResource
> "/>
>
> I still get the same 404 error when I try to access this service.
>
> On Thu, Jan 15, 2009 at 6:26 PM, Allan Ditzel
> <allan.ditzel_at_gmail.com> wrote:
> Hi,
>
> I was hoping someone might be able to help me out. I'm trying to get
> jersey integrated into our project at work, but it seems that the
> servlet isn't getting loaded. Here are my servlet and servlet
> mapping definitions:
>
> <servlet>
> <servlet-name>Jersey Spring Web Application</servlet-name>
> <servlet-
> class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</
> servlet-class>
> <!-- The following initialization parameter is only required
> for
> registering Jersey managed classes. Spring-managed
> classes
> are automatically registered.
> -->
> <init-param>
> <param-name>com.sun.jersey.config.property.packages</
> param-name>
> <param-value>com.company.path.web.rest</param-value>
> </init-param>
> <load-on-startup>1</load-on-startup>
> </servlet>
> <servlet-mapping>
> <servlet-name>Jersey Spring Web Application</servlet-name>
> <url-pattern>/rest/*</url-pattern>
> </servlet-mapping>
>
> Whenever I try to access anything in:
>
> http://localhost:8080/portal/rest (for example: http://localhost:8080/portal/rest/image/foo.jpg)
> , I get the following error:
>
> HTTP Status 404 - Servlet Jersey Spring Web Application is not
> available
>
> type Status report
>
> message Servlet Jersey Spring Web Application is not available
>
> description The requested resource (Servlet Jersey Spring Web
> Application is not available) is not available.
>
> Apache Tomcat/6.0.18
>
>
> Here is the resource that will be backing that service:
>
> @Path("/images")
> public class DynamicImageResource {
> /** Logger */
> private static transient final Log log =
> LogFactory.getLog(DynamicImageResource.class);
>
> /**
> *
> * @param imageName
> * @return
> */
> @GET
> @Path("{imagename")
> @Produces("image/jpeg")
> public byte[] getImage(@PathParam("imagename") String imageName) {
> /* ... code ... */
> }
> }
>
> Thanks in advance!
>
> Allan
>