users@jersey.java.net

Re: [Jersey] Re: jersey not mapping requests

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 24 Sep 2008 11:50:48 +0200

On Sep 24, 2008, at 10:50 AM, Tarjei Huse wrote:

> Hi, I managed to delete Pauls answer to my earlier questions, but I
> hope I mange to keep the posts in the thread.
>
> Paul wrote:
> > However, i recommend you try 0.11-ea-SNAPSHOT:
> > https://jersey.dev.java.net/source/browse/*checkout*/jersey/trunk/jersey/dependencies.html
> > which is very close to becoming 1.0.
>
> Now, I read that document, and updated my dependencies to 0.11-ea-
> SNAPSHOT. This worked with regard to maven. However, I did not mange
> to get everything working,
> and I got some new questions:
>
> 1. The document states:
> Spring
> Maven developers, using Spring 2.0.x or Spring 2.5.x, require a
> dependency on the jersey-spring
> module.
> The servlet:
> com.sun.jersey.spi.spring.container.servlet.SpringContainer
> is required to be referenced in the web.xml of the Spring-based
> Web application.
> Does this mean the servlet should be referenced on top of the normal
> com.sun.jersey.spi.container.servlet.ServletContainer or alongside it?

In replace of. If you were perviously referring to:

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

replace that reference with:

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

to obtain Spring support (see below, there is an error in the
documentation).

>
> I would be greatfull if you could provide example configurations for
> this in the document as several variants exist on the net[1] that
> seem to be wrong.

See here for an example:

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

>
> I ended up with the following:
> <servlet>
> <servlet-name>Jersey Spring</servlet-name>
> <servlet-
> class>com.sun.jersey.spi.spring.container.servlet.SpringContainer</
> servlet-class>
> <init-param>

You are missing the <param-name>, but it does not matter since this
param name/valueis not required to get package scanning support.

>
> <param-
> value>com.sun.ws.rest.api.core.PackagesResourceConfig</param-value>
> </init-param>
> <init-param>
> <param-name>com.sun.ws.rest.config.property.packages</param-
> name>
> <param-value>your.resource.package</param-value>
> </init-param>
> </servlet>
> <servlet-mapping>
> <servlet-name>Jersey Spring</servlet-name>
> <url-pattern>/service/*</url-pattern>
> </servlet-mapping>
>
>
> 2. When I tried to use the following dependencies:
> <dependency>
> <groupId>com.sun.jersey</groupId>
> <artifactId>jersey-server</artifactId>
> <version>0.11-ea-SNAPSHOT</version>
> </dependency>
> <dependency>
> <groupId>com.sun.jersey</groupId>
> <artifactId>jersey-core</artifactId>
> <version>0.11-ea-SNAPSHOT</version>
> </dependency>
> <dependency>
> <groupId>com.sun.jersey</groupId>
> <artifactId>jersey-spring</artifactId>
> <version>0.11-ea-SNAPSHOT</version>
> </dependency>
>
> I get a number of interesting exceptions:
> 2008-09-24 10:44:32.242:/:INFO: Initializing Spring root
> WebApplicationContext
> 2008-09-24 10:46:27.585::WARN: EXCEPTION
> java.lang.ClassNotFoundException:
> com.sun.jersey.spi.spring.container.servlet.SpringContainer
Ooopps there was an error in the documentation, it should be:

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

sorry about that, i have updated the documentation, and made it clear
about transitioning from non-Spring to Spring.

>
> I have also tried:
> com.sun.ws.rest.spring.SpringServlet
>
> as per [1].
>
> Links:
> 1. http://www.javakaffee.de/blog/2008/04/21/jersey-spring-integration-mostly-complete/
>
>
> So, what am I doing wrong now?

Nothing, it was my fault.

Paul.