users@jersey.java.net

Re: [Jersey] Deployment: provider recognized, but not instantiated?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 22 Apr 2010 22:06:39 +0200

Hi Laird,

I think there might is a bug in the MBW sorting algorithm.

https://jsr311.dev.java.net/nonav/releases/1.1/spec/
spec3.html#x3-440004.2.2

   4. Sort the selected MessageBodyWriter providers with a primary key
of media type (see section 4.2.3) and a secondary key
       of generic type where providers whose generic type is the
nearest superclass of the object class are sorted first.

and i am doing this the opposite for the secondary key, doh! So
MessageBodyWriter<String> is sorted before MessageBodyWriter<Object>,
rather than the other way around.

I am not sure if that issue is causing you problems or not. Hard for
me to tell without looking at all your code.

Anything in the logs to indicate an error constructing
RestDataSourceAdapter?

Paul.


On Apr 22, 2010, at 6:07 PM, Laird Nelson wrote:

> Following Paul's advice, for testing anyway, I now have a war file
> without a web.xml, and various provider classes in jars in the
> WEB-INF/lib directory. I also have an empty subclass of
> javax.ws.rs.core.Application that is annotated with @ApplicationPath.
>
> When I deploy this to Glassfish 3, I can see from the logs that my
> provider classes are found, but logging output that I would expect to
> see from them is never shown, and when it comes time to find a message
> body writer, I get the following error:
>
> [#|2010-04-22T10:12:08.796-0400|SEVERE|glassfish3.0|
> com.sun.jersey.spi.container.ContainerResponse|
> _ThreadID=30;_ThreadName=Thread-1;|A
> message body writer for Java type, class java.util.ArrayList, and MIME
> media type, application/xml, was not found|#]
>
> My resource class does indeed return an ArrayList<PersonEntity>.
>
> The message body writer which I intend to have handle everything never
> seems to be constructed, but is found:
>
> [#|2010-04-22T10:12:07.578-0400|INFO|glassfish3.0|
> com.sun.jersey.server.impl.application.DeferredResourceConfig|
> _ThreadID=30;_ThreadName=Thread-1;|Instantiating
> the Application class, named com.jenzabar.ngp.war.test.Application.
> The following root resource and provider classes are registered:
> [class com.jenzabar.ngp.smartgwt.jaxrs.RestDataSourceAdapter, class
> com.jenzabar.ngp.constituent.jaxrs.PersonResource]|#]
>
> My RestDataSourceAdapter is annotated like this:
> @Provider
> @Produces("application/xml")
> public class RestDataSourceAdapter implements
> MessageBodyWriter<Object> {
> //...
> }
>
> I have logging messages on entry, exit of every method. No logging is
> output. There is no indication that this message body writer is ever
> constructed.
>
> What have I done wrong?
>
> Best,
> Laird
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>