Daniel,
no it is neither a copy & paste error nor a typo. The description is written
basing on the 1.0 release of Jersey, and there it really is
<servlet-class>com.sun.jersey.impl.container.servlet.ServletAdaptor</servlet
-class>, while in the latest 1.0.2 release it is
<servlet-class>com.sun.jersey.server.impl.container.servlet.ServletAdaptor</
servlet-class>. It seems the package structure changed between 1.0 and
1.0.2.
Regards
Markus
From: Daniel Manzke [mailto:daniel.manzke_at_googlemail.com]
Sent: Sonntag, 8. Februar 2009 01:02
To: users_at_jersey.dev.java.net
Subject: Fwd: [Jersey] [WebDAV] How to register WebDAV with Jersey?
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.AddressBookApplic
ation</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