users@jersey.java.net

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

From: Allan Ditzel <allan.ditzel_at_gmail.com>
Date: Fri, 16 Jan 2009 09:44:38 -0500

Hi Paul,

We are using ivy to handle our dependency management and are pulling
dependencies from that maven repo. Here is the snippet of our ivy config:

<dependency org="com.sun.jersey" name="jersey-server" rev="1.0.1"
conf="web,test"/>
<dependency org="com.sun.jersey" name="jersey-client" rev="1.0.1"
conf="web,test"/>
<dependency org="com.sun.jersey" name="jersey-json" rev="1.0.1"
conf="web,test"/>
<dependency org="com.sun.jersey" name="jersey-fastinfoset" rev="1.0.1"
conf="web,test"/>
<dependency org="com.sun.jersey" name="jersey-atom" rev="1.0.1"
conf="web,test"/>
<dependency org="com.sun.jersey.contribs" name="jersey-multipart"
rev="1.0.1" conf="web,test"/>
<dependency org="com.sun.jersey.contribs" name="jersey-spring" rev="1.0.1"
conf="web,test"/>
<dependency org="javax.ws.rs" name="jsr311-api" rev="1.0" conf="web,test"/>

Our lib directory ends up with the following jar files for the above config:

jersey-atom-1.0.1.jar
jersey-client-1.0.1.jar
jersey-fastinfoset-1.0.1.jar
jersey-json-1.0.1.jar
jersey-multipart-1.0.1.jar
jersey-server-1.0.1.jar
jersey-spring-1.0.1.jar
jsr311-api-1.0.jar

Also, we are deploying inside of Tomcat 6 with JDK 6.

Best Regards,

Allan

On Fri, Jan 16, 2009 at 9:02 AM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:

> 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
>>
>
>
>