users@jersey.java.net

Re: [Jersey] not-working custom provider in Jersey 1.1 (?)

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 26 Jun 2009 15:12:58 +0200

Hi,

Glad things are working.

Given your set up there should be no scanning for resources because
you are referring explicitly to an implementation of Application that
does not do scanning.

I am presuming given your set up the following servlet declaration in
your web.xml should work:

  <servlet>
      <display-name>Jersey Web Application</display-name>
          <servlet-name>JSONThesauriServlet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</
servlet-class>
          <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>be.kvvcr.thesauri.rest</param-value>
          </init-param>
  </servlet>

Paul.

On Jun 26, 2009, at 3:00 PM, Bruno De Nys wrote:

>
> Thanks for your swift reply. I immediately noticed that your
> example worked.
> Hence the cause of the problem was probably in the setup/
> configuration of my
> project.
>
> The messages in the log-file of my tomcat 6.0.14 server made me
> conclude
> that my resolver was properly registered. This was a wrong
> conclusion. The
> solution was to explicitly include the resolver in the application
> that I
> had to register in the web.xml file.
>
> This is the excerpt of the web.xml file:
> <servlet>
> <display-name>Jersey Web Application</display-name>
> <servlet-name>JSONThesauriServlet</servlet-name>
>
> <servlet-
> class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-
> class>
> <init-param>
> <param-name>javax.ws.rs.Application</param-name>
> <param-value> be.kvvcr.thesauri.rest.ThesauriRestApp</param-
> value>
> </init-param>
> </servlet>
> and here is my new ThesauriRestApp (the line that was added is
> "s.add(JAXBXSLResolver.class);"):
> package be.kvvcr.thesauri.rest;
>
> import java.util.HashSet;
> import java.util.Set;
>
> import javax.ws.rs.core.Application;
>
> public class ThesauriRestApp extends Application {
>
> @Override
> public Set<Class<?>> getClasses() {
> Set<Class<?>> s = new HashSet<Class<?>>();
> s.add(DescriptorResource.class);
> s.add(JAXBXSLResolver.class);
> return s;
> }
>
> }
> There was one more hickup: the vendor specific JAXB extension for the
> xmlHeaders property is not available when using the JAXB-support of
> Java
> 6.0. As a consequence I had to copy a more recent JAXB
> implementation (I
> took the JAXB reference implementation 20081030) to the tomcat
> directory
> containing the bootstrap classes (and make sure it was loaded before
> loading
> rt.jar).
>
> The strange thing is that I now no longer see a message in my tomcat
> log-file saying that my resolver is loaded. It is as if the automatic
> scanning no longer works. I have no idea why at first the JAX-RS
> runtime
> scanned for my resource and now no longer scans for my resources.
>
> Anyway, things now seem to work as expected.
> --
> View this message in context: http://n2.nabble.com/not-working-custom-provider-in-Jersey-1.1-%28-%29-tp3149611p3161381.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>