users@jersey.java.net

Re: [Jersey] [WebDAV] How to register WebDAV with Jersey?

From: Daniel Manzke <daniel.manzke_at_googlemail.com>
Date: Sun, 8 Feb 2009 01:01:36 +0100

Hi,
which one should we use?

   1. com.sun.jersey.spi.container.servlet.ServletContainer
   2. com.sun.jersey.server.impl.container.servlet.ServletAdaptor


Bye,
Daniel

2009/2/8 Daniel Manzke <daniel.manzke_at_googlemail.com>

> Hi All,
> it looks like there was a little copy&paste error. The package of the
> ServletAdaptor is wrong.
>
>
> WRONG: <servlet-class>com.sun.jersey.impl.container.servlet.ServletAdaptor</servlet-class>
>
> RIGHT: <servlet-class>com.sun.jersey*.server*
> .impl.container.servlet.ServletAdaptor</servlet-class>
>
>
> I hope this helps you out, if tried Markus sample. :)
>
>
>
> Good Night from Germany,
> Daniel
>
> 2009/2/7 Markus KARG <markus.karg_at_gmx.net>
>
> Dear Jersey Community,
>>
>>
>>
>> as some people had problems registering WebDAV Support for Jersey with the
>> Jersey Runtime, here is a short step-by-step solution, basing on the quite
>> popular TomCat product:
>>
>>
>>
>> (1) Always use the latest WebDAV code.
>>
>>
>>
>> WebDAV is under heavy construction, so you should use the latest bug fixes
>> always. The code is found in SVN trunk (
>> https://webdav.dev.java.net/source/browse/webdav/trunk/core/jaxrs) and
>> can be built using "mvn clean install". Certainly the resulting library must
>> be either installed in the lib-folder oder TomCat, or must be part of the
>> lib-folder of your .war file.
>>
>>
>>
>> (2) Application class is obligatory.
>>
>>
>>
>> Chapter 2.1 "Configuration" of the JAX-RS 1.0 specification says: "The
>> resources and providers that make up a JAX-RS application are configured via
>> an application-supplied subclass of Application.".
>>
>>
>>
>> While this is not WebDAV specific so far, here comes the particular WebDAV
>> addition: You must implement the getSingletons method of your application in
>> a way that actively registers an instance of WebDavContextResolver, since
>> "WebDAV Support for JAX-RS" is implemented as a provider class in the sense
>> of the JAX-RS specification. Also, if you want to use custom extensions to
>> WebDAV, these must be registered in turn with the WebDavContextResolver so
>> "WebDAV Support for JAX-RS" will know how to handle them.
>>
>>
>>
>> Example:
>>
>>
>>
>> *public* Set<Object> getSingletons() {
>>
>> * try* {
>>
>> * return* *new* HashSet<Object>(Arrays.*asList*(*new*WebDavContextResolver(/* custom extensions to be listed HERE */)));
>>
>> } *catch* (*final* JAXBException e) {
>>
>> Logger.*getLogger*(AddressBookApplication.*class*
>> .getName()).severe(e.toString());
>>
>> *return* *null*;
>>
>> }
>>
>> }
>>
>>
>>
>> (3) Publication of application is obligatory.
>>
>>
>>
>> Chapter 2.3.2 "Servlet" of the JAX-RS 1.0 specification says: " When
>> using a non-JAX-RS aware servlet container, the servlet-class element of
>> the web.xml descriptor SHOULD name the JAX-RS implementation-supplied
>> Servlet class. The application-supplied subclass of Application is
>> identified using an init-param with a param-name of
>> javax.ws.rs-.Application.".
>>
>>
>>
>> Since this sample is using TomCat 6, and TomCat 6 is not JAX-RS-aware, we
>> have to do what the specification says.
>>
>>
>>
>> Example:
>>
>>
>>
>> <servlet>
>>
>> <servlet-name>ServletAdaptor</servlet-name>
>>
>> <!-- Tell Servlet-Container that we want to use JAX-RS -->
>>
>>
>> <servlet-class>com.sun.jersey.impl.container.servlet.ServletAdaptor</servlet-class>
>>
>> <init-param>
>>
>> <param-name>javax.ws.rs.Application</param-name>
>>
>> <!-- Tell Servlet-Container that we want to use WebDAV -->
>>
>>
>> <param-value>net.java.dev.webdav.samples.jaxrs.addressbook.AddressBookApplication</param-value>
>>
>> </init-param>
>>
>> <load-on-startup>1</load-on-startup>
>>
>> </servlet>
>>
>>
>>
>> That's it. This is the sole difference between Jersey in common, and
>> Jersey with WebDAV-Support. I hope you all now have more luck with your
>> WebDAV trials. :-)
>>
>>
>>
>> Have Fun
>>
>> Markus
>>
>
>
>
> --
> Mit freundlichen Grüßen
>
> Daniel Manzke
>



-- 
Mit freundlichen Grüßen
Daniel Manzke